Hi Doug,
If you use the Radio Button option for Pick Lists, the value you select is what’s stored in the field. If you use the Checkbox Buttons option for the Pick List, then Tap Forms will generate a comma separated values list that’s stored in the field. So treat them as text in a Calculation field or Script.
So that label position setting used to work. I’m thinking that it might be a Big Sur issue. Are you using Big Sur? I may have to turn it off on Big Sur if that’s no longer supported as a feature in macOS.
Thanks,
Brendan
Hi Sam,
I would like to use your example for presenting a pop up list based on the selection from the first pick list but I am a complete novice and unsure where I should put the script – do I create script fields or do I create text fields using the pick lists and then put the script somewhere else?
kind regards
Mike
Hi Brendan, 5 years into using TF and I love it. I’m no guru however always building and developing Various TF databases for me and my family.
My query is..
I’ve got a main form that pulls data from another x7 child forms, I output the info in pdf via email. Is there a way I can have a basic TF control to manage a page break in the output.
I’m thinking a feature similar to a “section heading” function, so I can preset a number of fields above the page break etc. Please note I haven’t learnt scripting yet.
You thoughts would be welcome.
Cheers Anthony
Hi,
Is there a way to update only selected entries? For me, the menu entry is always gray, either in table view or list view (see screenshots).
If you select “Refresh record list”, Tap Forms recalculates all entries. This takes a particularly long time if you have many entries (with scripts and calculations). Especially when you are in a child form entry you only want to update the associated entries and not all of the forms in the background.
Is this a mistake or am I doing something wrong?
Thanks to all.
Chris
Attachments:
You must be
logged in to view attached files.
Yeah, I think I will eventually end up with one field or three, but for now it seems like I should go with two: 1 containing the exact dates I know and another for the fuzzy dates. I might eventually run one of Daniel’s scripts and just use the text, but for now it is just data and I feel like maybe I should accumulate a little more before I decide what is really best in the future.
If you need flexibility in representation, a text field is probably the best option. Having two fields would confuse things and I think you’d want to end up with three: one for precise dates with the picker, a text field for approximate dates and then a calc or script field for display that displayed the precise date or approximate date based on which value is set. On the Mac, a layout would help with display but for data entry you’d need both fields visible. You could potentially script it but at that point you’re losing the date picker UI functionality so you might as well just use a text field.
There are two problems with making this happen now: the first is that as far as I know the Tap Forms’ Siri integration doesn’t have a way of passing data into it to make that happen and the second is that the Siri Intent API is rather prescriptive on how phrases are defined by the application ahead of time without a run time ability to handle it dynamically.
What I’ve done before is using Siri Shortcuts and setup prompts within it and used the CouchDB integration to do Siri Shortcut based creation with prompts. It’s not the easier thing to build in the Siri Shortcuts interface, particularly on a phone, but it is a pathway that does work. It requires you to have access to that web infrastructure to answer the question though.
This seems the right place to ask. What I’d like to do is to have Siri search for a trimming that is in a particular field database file or field. I have a data base of things and if I’d like to be able to look something up and have Siri read back the item.
By way of simple example, say I have a database of widgets. “Hey Siri what is the size of widget # 37”. The shortcut would tell Siri to look in file xyz.db in the # field and return the size field.
That seems to be doable in AppleScript (I think), but I’de like this as a iPhone/iPad shortcut of course.
Thanks! So if I choose to go this route, I need to be careful with the date format. I am currently using Jan 26, 2018 as I described above. It looks like this script will now use 20180126, which isn’t easily readable. Or am I getting the syntax wrong?
It would be nice if it was readable and sortable, and these seem to sort correctly: 2018/01/28 and 2018 and 2018/01? Still kind of ugly, though. Is there any reason to use – instead of / or do special characters not have any hidden meanings?
I suppose I could just use a text field, but even that would be annoying because if I convert an existing Date field to a text field, the data is erased. I already have 200 records, so converting to text would require me to cut and paste the existing date 200 times.
You could use a form script to translate the date field into a text field.
Following script would do that. You just need to update date_id and text_date_id to match your form.
function Convert_Date() {
var date_id = 'fld-f74f442f93b7499aba86170cbab5e3a1';
var text_date_id = 'fld-87e6c288a4e042c1bbfff27849a4b224';
// loop over all records
for (rec of form.getRecords()){
let date = rec.getFieldValue(date_id); // get date
if (date){ // if date exists
let textDate = date.toLocaleDateString("en-US", { year: 'numeric', month: 'numeric', day: 'numeric' }); // create date string
console.log(textDate);
rec.setFieldValue(text_date_id, textDate); // store date string
} else {
console.log("Empty date");
}
}
document.saveAllChanges();
}
Convert_Date();
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
That’s awesome! I’m so glad!
The scripting is powerful, but it also has a fairly steep learning curve. I have an intro to scripting here: http://cattail.nu/tap_forms/tap_forms_scripting_101/index.html
– T
Great explanation Sam.
At some point I would like to add triggers to run Form Scripts based upon a specific set of events. I know you asked for this eons ago Sam.
A script field would work.
var when_id = 'fld-a13ae3e64dd340138d08e719fe2a9aa9';
var childform_id = 'fld-8ead2e10d2634bd4925175d72f943857';
function Max() {
var arr = record.getFieldValue(childform_id);
arr.sort(compare);
return arr[0].getFieldValue(when_id);
}
function compare(a, b) {
if (a.getFieldValue(when_id) > b.getFieldValue(when_id)) {
return -1;
} else if (b.getFieldValue(when_id) > a.getFieldValue(when_id)) {
return 1;
}
return 0;
}
Max();
You will need to get your field ID’s.
Make sure you set the return results type to Date.
Calculation and Script fields are automatically run each time a field they reference is updated within a record. A script field can then change other fields in the record as well which can optionally also trigger scripts that watch those fields (a behaviour that can be disabled if needed to avoid cycles or other behaviour that might not be intended). Calc and script fields are also evaluated when a record is created.
Form scripts are executed on demand and you can execute them against the currently selected record (in which case record is populated) or you can apply it to all records in the form (form is populated which has a getRecords() method). There is also another special search variable that is populated when you’re working with a search (you can do typeof(search) !== "undefined" to see if it is set).
Hi! Is there a way to run a script on a record change or save event? And can I modify just one record with a script, or does a script have to modify all records in a form?
What other events are there?