Got it, with an experimental field.
Now, what happens if I change an Numeric field to an incremental stepper field? Do I lose the data or does the data remain and I can increment it?
BTW, I read the increment field information before I asked the question and what you said is clear, but in the manual on line it was very confusing and I thought it said the field would increment anytime the record was opened (my memory) so that is why I asked about scripting.
I have a field that holds a numeric value. I have to select that field, delete the number that is there and replace it with a number + 1.
Is there a way to increment a numeric value without going to all that work with a script?
Hi Tim,
The tricky part is getting the list of records for just the month and then total that up. You could do it, but it would require writing some JavaScript in a Script field to get the list of records, loop through them to find which records match the month you’re interested in seeing and then totalling up the value from your amount field, then returning that value so it displays in the script field on your record.
There is a simple function called form.getTotalOfField(fieldID); to get the total of a field from a form, but the tricky part in your case is to get the total just for a specific range of records.
How’s your scripting ability?
Thanks,
Brendan
In the script editor, clicking on the symbol to the right of fx (highlighted in the attached image) opens the Select a Field prompter. There I select field_id followed by the field of interest. This creates the typical field definition in the code:
var field_name_id = 'fld-xxx';
Attachments:
You must be
logged in to view attached files.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
The really great script editor on the desktop version makes it easy to get and use a field_id by clicking in a list. Is there an easy way on mobile to get a particular field_id? Or, do you manually need to do that in code, using perhaps, getFieldIds()? Thank you.
-
This topic was modified 2 years, 8 months ago by
alang.
Ah! Just starting to learn scripting. So that’s very helpful. Thank you again!
-
This reply was modified 2 years, 8 months ago by
alang.
-
This reply was modified 2 years, 8 months ago by
alang.
I forgot to mention, the Child Records Loop snippet on the Script Edit window will write most of the code for you. Just add a Script field to your parent form, then open the Script edit window. Then select a field from the Link to Form field on the list of fields on the left of the Script Edit window. Then double-click on the Child Records Loop snippet. Tap Forms will write the code you need to loop through all the child records. Then just join the value from the field into an array using the push() function and then join them together as a string using the join(", ") function.
Hi Tom,
You can do this with the DATEADD() function and the IFEQUAL() function.
For example:
DATEADD(Date;0;IFEQUAL(Service Interval; "Filter"; 14; IFEQUAL(Service Interval; "Tubing"; 90; 0)) ;0;2;0;0;0)
the IFEQUAL() function takes 4 parameters. A field, a value to compare the field with, a return value if the field equals the value, otherwise another value if they’re not equal.
It does get a little complex when you’re embedding functions within other functions. It’ easier to understand scripting code though, so you could also do this using JavaScript.
Hope that helps!
hi Alang,
This can be done if you create a Script field which joins together values from a field that you want to extract from the Link to Form field.
You could have multiple records in your Link to Form field, so you have to tell Tap Forms which record to get the value from. Or you can just loop through all of the child records and join the values together into a single string. That could then be displayed in the multi-column list view.
Thanks,
Brendan
Hi Wil,
You can do this sort of thing with a Script.
Are you able to write JavaScript?
https://www.tapforms.com/help-mac/5.3/en/topic/scripts
You would need to use the JavaScript substring() function to extract out the text you want:
https://www.w3schools.com/jsref/jsref_substring.asp
And the indexOf() function to locate the string you want to split the text from.
Not sure how adept at JavaScript you are, but it’s definitely possible to do what you want.
Thanks,
Brendan
I have a use case of creating some maintenance logs for several items. An example is routine maintenance and replacement items on a CPAP machine. I am having trouble figuring out how to auto populate the next service date. The next service date is based on the specific item and the needed interval. I can get it to add X number of days to the entered current service date. But I can’t adjust the service interval based on the item selected. Trying to do IF “Filter” then interval = 14 and things like that. Only using the DATEADD function has worked for me but I can’t figure out how to make the # of add days a variable.
Not sure if this can all be done with calculations or needs scripting.
Simple case with fields and values is as follows:
Item: From pick list choose. Filter, Tubing.
Date Serviced: Enter date serviced.
Next Service Date: Auto calculate based on Item selected and service Interval.
Comments:
Service intervals: Filter – 14 days and tubing 90 days.
An help and or recommendations would be greatly appreciated.
Thanks,
Tom
-
This topic was modified 2 years, 8 months ago by
Tom Seputis.
Hi Da,
You can use the Scripting functionality to post any Tap Forms content to a web service now.
See the scripting topic in the online user manual here:
https://www.tapforms.com/help-mac/5.3/en/topic/scripts
There’s functions for posting and getting content from any web service. There’s even an example script on that page that shows you how to call out to a web service to fetch movie data given a barcode value.
Thanks,
Brendan
Daniel,
Thank you. You are right I was looking at SQL rather than JavaScript.
Even replacing OR with || still generated an error. It was only when I realised that there was an extra “(” which caused still caused an error:
if (DocumentType.includes("passport") || *(*documents_details.includes("passport")) {
before the document_details variable…
The SQL documentation doesn’t really help much as this is Javascript that you should refer to: https://www.w3schools.com/js
The logical OR operation in JS is ||. includes is a method used on arrays, you might look at match instead (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match).
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
I have two variables in a script (DocumentType or Documents_Details). One or the other contains text.
I wish to see if either of them include a specific word (Passport).
I set up an IF condition to test:
`if (DocumentType.includes(“passport”) OR (documents_details.includes(“passport”)) {
console.log(“there is a passport here”);
} else {
console.log(“there is NO passport here”);`
But get an error message:
“I-CertDoc: SyntaxError: Unexpected identifier ‘OR’. Expected ‘)’ to end an ‘if’ condition., line:153”
I tried to follow what is on this page: https://www.w3schools.com/sql/sql_and_or.asp, but it is not producing the desired result. Any help would be gratefully received.