- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 05:57 PM
I have a Yes/No variable, and the entry needs to get populated in 2 Yes/No read-only boxes farther down the form. Is there a simple script to make this happen?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 03:38 PM
Good point! It's a Yes/No field so there's only 2 choices so that'll do.
Need to check "Reverse if false" in that case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 06:28 PM
Hi, if you are wanting to populate the values in the UI, IE when the field is changed update the form values
Then you would use an onChange() client script against the field that is changed, then set the target field values based on the newValue.
either
//Values will always match the source field
g_form.setValue('yourFieldName1', newValue);
g_form.setValue('yourFieldName2', newValue);
//Or set based on the newValue
if(newValue == 'true') {
g_form.setValue('yourFieldName1', newValue);
g_form.setValue('yourFieldName2', newValue);
}
//Or set as required
if(newValue == 'true') {
g_form.setValue('yourFieldName1', 'true');
g_form.setValue('yourFieldName2', 'false');
}
If you do not need to see the values in the form prior to saving, you could also use an onBefore() insert\updateBR and assign the values to the target fields based on the above scripts referencing the current object. IE
current.yourFieldName1 = current.yourReferenceField;
current.yourFieldName2 = true;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 07:29 PM
It's a Yes/No field type.
The first will work but the later would not because the code is comparing with "true" and "false" instead of "Yes" and "No".
Following is OK.
//Values will always match the source field
g_form.setValue('yourFieldName1', newValue);
g_form.setValue('yourFieldName2', newValue);
Other two should be as follows:
//Or set based on the newValue
if (newValue == 'Yes')
g_form.setValue('field3', newValue);
else {
g_form.setValue('field3', newValue);
}
//Or set as required
if(newValue == 'Yes') {
g_form.setValue('yourFieldName1', 'Yes');
g_form.setValue('yourFieldName2', 'No');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 03:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 04:45 PM
Oh duh, im a dummy.... Thanks Hitoshi. Totally wasn't thinking about the right way. UI Policy is the way to go, thanks