Possible to limit spawn(ed) page(s) using script in a calculate field to a single execution?
- September 25, 2023
- 1 reply
- 5131 views
I am having difficulty limiting the following script to a single execution upon tabbing to the next field... I've tried placing it in the "Actions-->Mouse Up-->Run a JavaScript" where it will only execute after tabbing out of the field and then going back to the field (via 'shift-tab' or mouse cursor, which is entirely unacceptable. I've placed it in the calculate field to ensure it runs after a numeric entry as I have not figured out a way to avoid the 'Run a JavaScript' tabout/mouse cursor limitation.
Is there possibly a line of script that may prevent the script from running more than once in the calculate field after it has executed? Or is there a method that can be implemented within the 'Run a Javascript' to ensure single execution upon tabbing to the next field?
My sincerest thanks in advance for your assistance.
EDIT: Apologies, I failed to add a test reference document.
The script works as written excepting the subject line
var templateCountField = this.getField("EQUIP.No");
var pageCount = parseInt(templateCountField.value);
var temp
if (!isNaN(pageCount) && pageCount > 0) {
for (var i = 0; i < pageCount; i++) {
this.getTemplate("EQUIP.TEMP").spawn();
}
} else {
app.alert("Please enter a valid positive number in the 'Equipment Number' field.");
}
this.getField("Narrative").setFocus();
