- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 01:06 AM
We have a list collector field on record producer. we have created four values in the question_choice table and added the reference qualifier to the list collector field.
requirement: if the user selects one value and then if he tries to select 'none of the above' value along with the other value selected,it should throw field error message.
i.e User should select either a/the valid option(s) or only 'None of the above' option for the list collector field. Both values cannot be selected at the same time.
list collector field name: Could the AI system be used to do any of the following without substantial modification? (check all that apply)
values:
what logic to implement in the onchange catlog client script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 04:17 AM
You can do this with an onChange Catalog Client Script when this variable changes. List Collectors store the value as a comma-separated list of sys_ids for records on the referenced table, so your script would look like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue.indexOf('c938b7111b121100763d91eebc0713f0') > -1 { //None of the above selected
var arr = newValue.split(',');
if (arr.length > 1) {
g_form.addErrorMessage('Other options cannot be selected when selecting None of the Above.');
} else {
g_form.clearMessages();
}
} else {
g_form.clearMessages();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 04:17 AM
You can do this with an onChange Catalog Client Script when this variable changes. List Collectors store the value as a comma-separated list of sys_ids for records on the referenced table, so your script would look like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue.indexOf('c938b7111b121100763d91eebc0713f0') > -1 { //None of the above selected
var arr = newValue.split(',');
if (arr.length > 1) {
g_form.addErrorMessage('Other options cannot be selected when selecting None of the Above.');
} else {
g_form.clearMessages();
}
} else {
g_form.clearMessages();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 05:31 AM
Hey Brad, thanks for the quick response. 🤗
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 01:26 AM
Hi Brad,
Now after displaying the field error message, I need to remove the recent value selected. I have used the arr.pop() method .
But now, the error error message shows up only for a flash of time and it disappears. I want the error message to stay after the recent value is removed also.so that user can read the message and input correct values.
The error message stays if arr.pop() not used.
i need to remove the last selected value and still keep the error message on, so it is visible to user.
kindly help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 05:50 AM
That's tricky with an onChange script since the arr.pop() is causing another change. So you can either get rid of the two else blocks so that the message remains, but then it will be there until the form is submitted. The other easy option is to not remove the last selected value, then have a similar onSubmit script so that the form cannot be submitted when this condition exists.