Also, you can have a Script Field just return its data and display it on a custom layout. You don’t have to set another field with the result just to display the result.
Text can be placed on a Form as part of the layout using the “A” icon labeled: “Add text to your layout”. Is there a way to get an object id of that text object. This would be to change the text via scripting as you do with regular form objects. Thank you.
-
This topic was modified 2 years, 11 months ago by
alang.
You don’t need a separate field to contain the results of the Script field execution. You can just display the Script field directly because whatever you return from the Script will be displayed by that field. If the relationship field is the inverse of a One to Many (that is, a Link From Form field), then the Calculation field formula can also return that value and takes just a single double-click on the Formula Edit screen for the Calculation field.
I see. Thank you. On the form I am linking to are several fields that are themselves, “Link To Form”. So they, of course, are not available to display in the popover (or the left of the child form itself). I do need some combinations to appear in the popover. For example, the child form used to populate the popover, called Sources includes books titles. A field on Sources is Authors, which itself, is a “Link To Form” (to Authors) since a book might have several authors. What I want to appear in the popover populated by Sources would be, for example, a principle author (identified somehow in the authors form) plus the book title. So given what you have said, I am thinking that I need to utilize either a calculation field or a script field to extract on the sources form, for each record, book title plus author. The scripting would need to select which author. I would take that title plus author and place it in a regular text field on the form, Sources (the child form that will populate the popover). This plain text field, populated by the script with author-title, would then appear as a field to select for the popover. If I managed to make that clear, does it sound like I am headed down a reasonable path? Or does a better approach come to mind? Thank you.
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, 11 months ago by
alang.
Ah! Just starting to learn scripting. So that’s very helpful. Thank you again!
-
This reply was modified 2 years, 11 months ago by
alang.
-
This reply was modified 2 years, 11 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, 11 months ago by
Tom Seputis.