Also, I guess as an example for the second option I am asking how one could script a field to define it’s own pick list selection array.
Essentially I would like to expand on cascading Pick Lists using scripting, since it appears not possible otherwise. It is a pretty typical database record scenario.
So the task would be to pre-populate a second (child) Pick List Field choices based on a selection in a first (parent) Pick List Field (first setting the default value if defined).
It would be cool if you could define a field based on the value found in another field. I can imagine two ways to do it, one would be as I describe above based on pre-existing pick lists (which has some advantages). The second more complicated way would be to have the script define a new pick list internally based on arrays defined within the script.
I am just wondering if either is already possible or a simple example exists that I could follow as a starting base?
In my case, the parent pick list could contain values that are the titles of the related child pick lists.
I’m trying out Tap Forms 5 on MAC (Catalina), Still in the trial period. I imported this template but am unable to run it successfully.
When I run the script, it creates a new record (titled ‘No’), but it is blank. No information about the show is imported.
When I run the script again the script console gives this error “series already exists undefined”
When I run the script a third time with a different show URL I get the same error again. “series already exists undefined”
1st URL Provided: https://www.imdb.com/title/tt8712204/
2nd URL Provided: https://www.imdb.com/title/tt3107288/
Do anybody have any suggestions?
If you tap on the Fields button at the top of the keyboard on the Script Editor, you’ll see a list of fields in your form. There’s a segmented control button that lets you have Tap Forms generate a getFieldValue() command or to generate a variable with the field ID. Tapping on the field will insert the code into your script.
There’s the Script API in the docs and also there’s the Script Talk forum where you can ask questions about scripting plus see the scripts others have posted.
Script Talk
https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api
I also looked but can’t seem to find a reference as to how to determine the Field ID address when using Tap Forms iPad app to programs script. Is there a built in way, or a Form script to run to print out a list to screen?
Thank you! Extremely useful. I guess I really am going to need to learn JavaScript to some extent.
Is there a library of pre-made script examples that I have missed located in a Github or some other place?
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
(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.
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.
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 :)
Yes, the script finished.
Tapping on the progress is closing it, otherwise it will run in an endless loop until next Christmas ??
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.
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.
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
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