Search Results for 'script'
-
Search Results
-
I’ve a simple form with two date fields (start and end) and some other fields. The first date field is populated with the current date. The second date field is empty. And some fields are hidden until the second field contains a date. To make it easier for the user, I’ve added a button to a Universal layout. When I click the button, the date field should be filled with the current date. I use this script for the task:
function MyScript() { var field_id = 'fld-b64c54dfb3de446fbf2b25b203c90104'; record.setFieldValue(field_id, new Date(), true); record.refreshCalculations(); form.saveAllChanges(); document.saveAllChangesAndRefresh(); record.refreshCalculations(); } MyScript();As you can see, I tried a lot to make the button work. But it doesn’t. After clicking, nothing happens. When I click on an empty area of the form, the second date field shos its content. But the hidden fields are still hidden, I’ve to switch layouts or record to let Tap Forms update the screen.
Is there a way to refresh the view? Or did I something wrong?
Hi Brendan,
I’ve noticed what seems to be a grouping issue with Number fields in Tap Forms Pro.
If a Number field contains a value and I delete that value, the field correctly appears empty. However, when I use this field with Group Records By, the record is placed in the 0 group, as if the empty field actually contained the value 0.
I checked the value with a script:
var value = record.getFieldValue(‘fld-0de…….’);
if (value === undefined) {
return “UNDEFINED — no value”;
}return “VALUE: ” + value;
For the affected record, the script returns:UNDEFINED — no value
So the Number field really is empty and does not contain 0. It seems that Group Records By is treating undefined and the numeric value 0 as the same grouping value.
Would it be possible for empty Number fields to remain in a separate empty group, rather than being grouped together with records whose value is actually 0?
Thanks!
Hi Brandon,
hi all,I have been experimenting with a script in the last couple of days and ended up with a reproducible crash of Tap Forms with one version of it, that I thought that someone might want to look into. (Disclaimer: AI helped me write the script as my capabilities in JavaScript are beginner level at best).
What I was doing: I have a script button on a custom layout that lets me pick an existing record from another form and link it via record.addRecordToField(), using Prompter.new() with a ‘popup’ parameter to show the choices. To add several linked records in one go, we wrapped that in a while loop and added a second Prompter (a simple Yes/No confirm using addParameter(message, null, “label”)) asking “add another?” after each pick.
The bug: As soon as this script has two different Prompter-based functions in it — even though the second one (the confirm) is never actually reached — the very first prompt crashes the whole app the moment I click its Continue button. It’s 100% reproducible, happens both from the live layout button and from the script editor’s own Run button, and happens regardless of which item I pick in the dropdown (including leaving it on the default first item).
If I strip the script down to a single Prompter call with no loop and no second Prompter function anywhere in the script, it works perfectly every time.
Here’s the full script that causes the crash:
async function Pick_Subtheme() {
await pickSubtheme();
}async function pickSubtheme() {
var keepAdding = true;
while (keepAdding) {
var chosen = await promptPopup(“Add a Subtheme:”, “Pick Subtheme”, [“Episode IV – A New Hope”, “Episode VI – Return of the Jedi”, “Classic Star Wars”, “Lego Star Wars – Ultimate Collector’s Series”]);
if (!chosen) { keepAdding = false; break; }
// … link the chosen record …
keepAdding = await promptConfirm(“Add another Subtheme?”, “Add Subtheme”, “Done”);
}
}function promptPopup(message, popupName, valuesArray) {
return new Promise(function (resolve) {
choice = undefined;
var p = Prompter.new();
p.addParameter(message, “choice”, “popup”, valuesArray, valuesArray[0]);
p.cancelButtonTitle = “Cancel”;
p.continueButtonTitle = “Add”;
p.show(popupName, function (status) {
resolve(status === true ? choice : false);
});
});
}function promptConfirm(message, continueTitle, cancelTitle) {
return new Promise(function (resolve) {
var p = Prompter.new();
p.addParameter(message, null, “label”);
p.cancelButtonTitle = cancelTitle;
p.continueButtonTitle = continueTitle;
p.show(message, function (status) {
resolve(status === true);
});
});
}var choice;
Pick_Subtheme();The crash happens the moment I click “Add” on the very first popup — execution never even reaches promptConfirm.
Crash log (Thread 0, the crashed thread):
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Reason: *** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]Termination Reason: Namespace SIGNAL, Code 6, Abort trap: 6
Terminating Process: Tap Forms Pro [31720]Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
…
10 CoreFoundation -[__NSArrayM objectAtIndex:] + 592
11 Tap Forms Pro 0x104f1a564 0x104dd0000 + 1353060
12 CoreFoundation __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
…I am using Tap Forms Pro 1.3.1 (Build 560) with macOS Tahoe 26.6.2.
I’m happy to send the full crash report if useful. Thanks for looking into it!
Melanie
In my Document there are a number of Forms, each of which has a field (all called “Import”). For some records in the Import field in each Form there is a letter “X”.
This setup distinguishes records imported from another database. After some work on the imported records, I wish to delete the content of the fields which contain the “X” (not the record itself).
The (Form) script I have to do this is below (one for each Form).
However, I have to go into each Form and run the script.
Is there a way:
1. to run all the scripts at once (one after another)?, or
2. to have a (Document) script which can go into each Form and delete the X in the Import field.The script:
var importFieldID = 'fld-6514c959cf9d4b169d3696a6ba49a56b'; [Changed for each Form] // Get all records in this Form var records = form.fetchRecords(); var changed = 0; for (var i = 0; i < records.length; i++) { var rec = records; // Get the value of the Import field var value = rec.getFieldValue(importFieldID); // Only clear records where Import is exactly X if (value == 'X') { rec.setFieldValue(importFieldID, ''); changed++; } } // Save the changes document.saveAllChanges(); console.log('Records changed: ' + changed);Any help would be gratefully received.