Copy link to clipboard
Copied
Would like to set 1 of 4 check boxes as "On" based on the value entered into a field with text field custom calculation , i.e.,
Enter 1 in field for "Check Box1" = "On"
"Check Box2" = "Off"
"Check Box3" = "Off"
"Check Box4" = "Off"
Enter 2 in field for "Check Box1" = "Off"
"Check Box2" = "On"
"Check Box3" = "Off"
"Check Box4" = "Off"
and so on...
Appreciate any help with this, thank you!
1 Correct answer
You should give all the check-boxes the same name (say, "Check Box1"), and unique export values (1-4), and then use the following code as the custom calculation script in the text field:
if (event.value) this.getField("Check Box1").value = event.value;
else this.getField("Check Box1").value = "Off";
However, this will fail if the user enters some unforeseen value into the text field, such as "5" or "X"...
Copy link to clipboard
Copied
You should give all the check-boxes the same name (say, "Check Box1"), and unique export values (1-4), and then use the following code as the custom calculation script in the text field:
if (event.value) this.getField("Check Box1").value = event.value;
else this.getField("Check Box1").value = "Off";
However, this will fail if the user enters some unforeseen value into the text field, such as "5" or "X"...
Copy link to clipboard
Copied
Bingo! Thank you
The script does fail in the sense that none of the check boxes have a check, that is OK with me. The user of the form can always easily restart, however a warning or error message would be nice to add if an undesired value was input into the field. Still learning, but I have what I need for now.
Script for future references:
var cAsk = "Enter One of: 1-Reviewed, 2-Rejected, 3-Revise, or 4-Furnish: ";
var cTitle = "Stamp status";
if(event.source.forReal &&
(event.source.stampName == "#axeWj0ZPWvEDlCFsbdmjaD"))
{
var nCheck = app.response(cAsk, cTitle);
event.value = nCheck;
}
if (event.value)
{
this.getField("CHECKBOX").value = event.value;}
else
{
this.getField("CHECKBOX").value = "off";}
Copy link to clipboard
Copied
NOTE:
StampName "#axeWj0ZPWvEDlCFsbdmjaD" is specific for each individual stamp, name must be changed for anyone else trying to use the code.

