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,086 through 2,100 (of 2,952 total)
  • Author
    Search Results
  • #38920
    Brendan
    Keymaster

    Hi Wayne,

    The IF() function takes 3 parameters. The first parameter MUST be a numeric comparison, not a textual comparison.

    For textual comparisons, use the IFEQUAL(X; Y; A; B), where X and Y must be textual and A and B can be anything that matches the Result Type specified on the formula editor. It means if X = Y, then return A, otherwise return B.

    So you would do:

    IFEQUAL([Unit]; "inches"; FORMAT([Value] / 12; "0.00"); "N/A")

    The reason for the FORMAT() function in there is because you’re returning "N/A" and that’s text, so your whole function needs to return Text. The FORMAT function will convert a numeric value into a textual representation. Plus it lets you format the resulting value. In this case in a decimal format with 2 decimal places. E.g. 1.20

    Yes, you can nest IF functions.

    IFEQUAL([Unit]; "inches"; FORMAT([Value] / 12; "0.00"); IFEQUAL([Unit]; "yard"; FORMAT([Value] * 3; "0.00"); "N/A"))

    But JavaScript would be much simpler to read:

    var value_field_id = "fld-.....";
    var unit_field_id = "fld-.....";
    var value = record.getFieldValue(value_field_id);
    var unit = record.getFieldValue(unit_field_id);
    var result = "";
    
    if (unit == "inches") {
       result = value / 12;
    } else if (unit == "yard") {
       result = value * 3
    } else {
       result = "N/A";
    }
    
    return result;
    

    I haven’t run the above code. It’s just off the top of my head, but that’s the gist of it.

    Thanks,

    Brendan

    #38909
    Wayne Powell
    Participant

    (I’m just beginning to use Tap Forms in a more sophisticated way than I have before).

    I am trying to replicate a Calculation Form, such that you enter a Value, and a Unit, and Then have a calculation (or calculations) output conversion values.

    So I am thinking something like this:

    Value = 12
    Unit (from pick list) = “inches”
    Calculation Result (in Feet) = 1 Foot

    SO I am thinking something like this (but not suer if it can be done or I have the syntax incorrect or?

    IF([Unit] = “inches”, [Value]/12, “N/A”)

    Also, can I cascade the IFs such that I more or less replicate a complex If/Else calculation:

    IF([Unit] = “inches”, [Value]/12, IF([Unit] = “yard”, [Value]*3))

    Ultimately it would great to be able to utilize TWO pick lists so I can pick both the Input Units and the Output Units.

    I’m not great at programming scripts in JavaScript or how to implement them in Tap Forms (yet, If I was going to do that I’d probably switch platforms and learn to create an App in Swift.)

    Any pointers would be greatly appreciated.

    #38907
    Sam Moffatt
    Participant

    Awesome addition! I’ve just been dismissing and re-showing the progress bar for the use case I have. Is it possible to reset the state entirely to change the total as well? It’s a little weird now where the sheet pops in and out, if I could change the total and the label then I could show it once and then update the label and total as I shift between stages of a script.

    #38904
    Sam Moffatt
    Participant

    Yah even when it’s explicitly dismissed it still shows up after the script complete popup. The same script on the desktop dismisses the progress bar properly. Tapping at least dismisses the pop up though so it’s not too bad in the grand scheme of things :)

    #38902
    Marcus
    Participant

    Yes, the script finished.
    Tapping on the progress is closing it, otherwise it will run in an endless loop until next Christmas ??

    #38901
    Sam Moffatt
    Participant

    I gave this a spin and the script finishes but the progress bar is still there. Tapping on it dismisses but it should probably disappear automatically. Same script on desktop works ok.

    #38900
    Marcus
    Participant

    Hi,
    first if all, Merry Christmas ?

    I noticed the following behavior of the progress bar on iOS (iPhone):

    Run a script
    Select the script
    Confirm to run the script
    Confirm Script run complete
    “Processing Records…” does not disappear

    I took the example from the API documentation:
    https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api

    btw.: A disable/enable option in settings
    to confirm to run/run complete scripts would be a nice feature.

    Brendan
    Keymaster

    Hi Chris,

    I’ll have to look into this issue.

    In the meantime, a Script Field would do the job without this issue.

    Can you please email me your form template and I’ll test with what you have?

    Thanks,

    Brndan

    #38873

    Topic: Add record

    in forum Script Talk
    Gilbert Heintje
    Participant

    Hello,
    I have 2 forms: form_A & form_B, and a script in form_A,
    question: how can I, in this script, create a new record into form_B? There is no link between the 2 forms.

    Thanks,
    Gilbert

    #38867
    Sam Moffatt
    Participant

    Siri executes scripts in a form context not a record context. Siri doesn’t have the context that Tap Forms is executing in and the intent that is being executed I believe is distinct from the main Tap Forms application. This is part of the way Apple have implemented the Siri support.

    I also have struggles using Siri with clipboard access, scripts invoked from Siri don’t seem to have access to the clipboard but when I run those same scripts manually they are able to pull the clipboard properly. I’m not sure if writing to the clipboard would have a similar problem.

    #38865
    Marcus
    Participant

    Maybe I‘m missing something, a basic question how to use Siri to run a script.

    I am in the record edit view and want to copy a field value to the clipboard.

    The script works fine by executing manually:

    function Clipboard() {
    var title_id = 'fld-76b2c64fccc34c20b62b7d485f5bfa28';
    var clip = record.getFieldValue(title_id);
    Utils.copyTextToClipboard(clip);
    return clip;
    }
    
    Clipboard();

    I added this script to Siri, the result is just
    „.undefined“

    (iOS, iPhone)

    Attachments:
    You must be logged in to view attached files.
    #38859

    In reply to: Field level script

    Sam Moffatt
    Participant

    Calc and Script fields track which fields are referenced inside of them and then when those fields are changed, the calc/script fields are executed to update. Script fields have some nuance to them where you can break the detection but if you use the standard pre-supplied interface to add the fields it should be fine. Script fields in the editor will show a tick next to the names of the fields that they are tracking.

    Attachments:
    You must be logged in to view attached files.
    #38858
    Gilbert Heintje
    Participant

    Hello,
    New with TF5, I search a script example witch use a ‘Calculation field’ & an another with a ‘Script field’. When these fields are triggered ?
    Many thanks,
    Gilbert

    #38857
    Sam Moffatt
    Participant

    I tried something here with Siri Shortcuts and trying to marshal data with the clipboard but didn’t get very far. I could get Siri to capture some voice text and location data without too many issues, I can put it into a JSON object on the clipboard and if I run the form script directly in Tap Forms it seems to work. However as soon as I go “Hey Siri” I get an error saying the app took too long and I suspect the clipboard isn’t accessible from the intent. If there was a version of the Run Script intent that accepted a simple text input then I could use that with JSON.parse to manage structured data.

    #38856
    Sam Moffatt
    Participant

    I don’t think you could do that with a calculation field or standard pick list field, it doesn’t have that flexibility. The pick list setting is at the form level and realistically your values should be at the record level, that’d be a little challenging.

    You could use a form script with a prompter to ask for the three values one after the other and then set the corresponding fields in your form. It’s not entirely elegant but it would be functional.

Viewing 15 results - 2,086 through 2,100 (of 2,952 total)