Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 2,236 through 2,250 (of 3,011 total)
  • Author
    Search Results
  • #38109
    Stephen Abshire
    Participant

    I am writing a script that touches (read/write) several fields on the form. I am guessing at this point but I think that as each of these fields are touched within the script they are invoking the script again on their own which is causing strange results. Can anyone confirm that this is either possible / not possible and if it is possible how can I stop this behavior so that a script is only executed when one of the fields that are being touched invokes the script?

    #38093
    Sam Moffatt
    Participant

    I use a hidden field to save state of what fields used to be and then compare the new field value against the old one. There is no before change data so you have to grab it yourself.

    I also have another technique where with the script field, you can return a value. So you can use the script field itself to store the previous state and by accessing the script field with getFieldValue, you can then get at the previous value. When you finish up your script field, you return the previous value. If you have a few different values you want to track, you can use JSON.stringify and JSON.parse to serialise and unserialise the field value into an object in JSON.

    Hopefully that helps.

    #38090
    Daniel Leu
    Participant

    Richard, is your ‘Notes’ field of type text or note? Brendan’s description is for a note type field.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #38088
    Brendan
    Keymaster

    If you have a Script field and you use record.getFieldValue(field_id) within the script, Tap Forms will add that field_id to a watch list. So when the value of that field changes, the script will execute.

    #38083

    In reply to: Parent / Child Records

    Victor Warner
    Participant

    I am having difficultly making this work for me – would Brendan or another user be able to provide a simple worked example how this operates?

    I am finding JavaScript difficult and general guides are not, at least for me, helping in understanding how to apply much of the example snippets that Tap Form provides.

    Any help would be very gratefully received.

    #38079
    Stephen Abshire
    Participant

    Greetings,

    Is there a way that I can detect when a text field that uses a pick list has had a value change? Say for example it used to be ‘ABC’ and now it is ‘DEF’. How can I catch when the value has changed so I can script it? I suppose a hidden field could be used as a form of global variable but that seems like a hack.

    #38078

    In reply to: Table field type

    Stephen Abshire
    Participant

    Got it working just wrote a script for it.

    #38062

    In reply to: Table field type

    Brendan
    Keymaster

    From a script you can call form.getTotalOfField(field_id) to get the grand total value. There’s also an equivalent one for saved searches: `search.getTotalOfField(field_id)’

    However, it wouldn’t work for a Table field. I guess I need to add those functions to the Table field. You’d just have to write a script that loops through the records and totals the value of the sub-field and displays it on the parent form.

    However again, the Calculation field does have the ability to give you the total of a field from within a Table field. Just double-click on any numeric type field in your Table field on the formula editor and Tap Forms should print something out like TOTAL::Table Field::Sub-Field. That’ll give you the result you want.

    #38059

    In reply to: Table field type

    Stephen Abshire
    Participant

    That worked perfectly so one more follow-up question. Can I through script or calculation field access the auto sums/totals that the table creates for me? I need that value to feed another script on my form.

    #38053

    In reply to: Table field type

    Brendan
    Keymaster

    Table fields are sort of like forms themselves, but they don’t belong to any actual form. So you can’t write a Form Script attached to a Table Field.

    But what you can do is add a Script Field to your Table Field that checks the value of your Checkmark field and returns a sum if the Checkmark field returns 1. 1 is On, 0 is Off.

    Then you could simply tell Tap Forms to total up the result of your Script Field which will give you the grand total of only the checked items.

    #38051

    In reply to: Table field type

    Stephen Abshire
    Participant

    Greetings,

    Yes I was able to get things working but it did bring up a new question. Contained within my field of type ‘table’ I have a child field of type ‘checkmark’. The question is how do I respond to the click event (if this exists) so that I can run a script?

    Currently the table is giving me a sum of one of the numeric child fields which is usually great. What I need to do is a SUMIF so that a given row in the table is added to the total only if its checkmark field is checked. I am okay if I need to write a script to do the math but I don’t know where to put the script so that it responds to the checkmark click event. I would rather automate this if I can and not be required to manually fire a form level script.

    #38036

    Topic: Record Color

    in forum Script Talk
    Stephen Abshire
    Participant

    So I am playing around with the following script:

    record.setRecordColor(‘#ff0000’);

    Based upon given conditions I set the color I want and it works. The problem is when no conditions are met I don’t know how to reset the record back to the default color it is given when it was created. Any ideas how to do this? Also I am unsure how the text color is being set as this function seems to set the background color.

    #38027

    In reply to: Parent / Child Records

    Sam Moffatt
    Participant

    In the Script Editor, the linked form should show up on the left as an option. If you double click on the name of the form, it will insert the field ID for the Link to Form field. You can then use record.getFieldValue with that field ID and it will give you an array of records that are linked.

    If you look in the snippets at the bottom, there is a “child records loop” snippet. If you select a field from the child record and click on this, it’ll insert a premade loop for you that will iterate over all of the child records and also pull out the selected record.

    On the other side of a 1:M, record.getFieldValue can be used with a Link From Form field (enabled via “Show Inverse Relationship”) to retrieve the parent form.

    #38017

    In reply to: VLOOKUP Script

    Ron Kline
    Participant

    Have you ever tried this concept using script to access the other forms data rather than a link to form field?

    #38012

    In reply to: Scripting Time fields

    Martin Inchley
    Participant

    Please can I bump this, as the ability to call a correct time of arrival is crucial. Here’s a little extra info:

    Context: I’m in a GMT timezone, Mac set to auto, all normal, currently winter so not British Summer Time.

    Time Field: “Time of Arrival”. I want to extract the time from this field. It is currently set to 3.50 p.m.

    If I use this script:

    var time_of_arrival_id = 'fld-4957bec764cf480884d3c7f8cce5a271';
    var thisTime = record.getFieldValue(time_of_arrival_id);
    console.log(thisTime);

    the console reports: Thu Jan 01 1970 14:50:30 GMT+0000 (GMT).
    I.e it’s subtracted an hour from the time in the field.

    But if I add the JS function .toLocaleTimeString() to the console.log line:

    var time_of_arrival_id = 'fld-4957bec764cf480884d3c7f8cce5a271';
    var thisTime = record.getFieldValue(time_of_arrival_id);
    console.log(thisTime.toLocaleTimeString());

    the console reports 15:50:30, which is correct.

    I really need to know what’s going on, so that I can control it. Earlier in this thread, both Daniel and Brendan reported anomalies, but no one yet seems to have an explanation or a solution.

Viewing 15 results - 2,236 through 2,250 (of 3,011 total)