
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 11:19 AM
Hello,
My requirement is as follows:
Require user to rank the Avoid, Mitigate, Transfer and Accept fields using choice list options: highest, second highest, second lowest, lowest. The problem I am encountering is how to best prohibit the user from using the choice list options more than once.
I began working on a client script and was able to limit the choices in the Mitigate field based on the choice selected in the Highest field. However, I am struggling with the complexity of applying the logic to all the other fields. Is there an easier way to approach this task?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.clearOptions('u_business_disruption_mi');
g_form.clearOptions('u_business_disruption_tr');
g_form.clearOptions('u_business_disruption_ac');
if (newValue == 4) {
//Mitigate
g_form.addOption('u_business_disruption_mi', '', '-- None --', 1);
g_form.addOption('u_business_disruption_mi', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_mi', '2', 'Second Lowest', 300);
g_form.addOption('u_business_disruption_mi', '1', 'Lowest', 400);
//Transfer
g_form.addOption('u_business_disruption_tr', '', '-- None --', 1);
g_form.addOption('u_business_disruption_tr', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_tr', '2', 'Second Lowest', 300);
g_form.addOption('u_business_disruption_tr', '1', 'Lowest', 400);
//Accept
g_form.addOption('u_business_disruption_ac', '', '-- None --', 1);
g_form.addOption('u_business_disruption_ac', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_ac', '2', 'Second Lowest', 300);
g_form.addOption('u_business_disruption_ac', '1', 'Lowest', 400);
}
if (newValue == 3) {
//Mitigate
g_form.addOption('u_business_disruption_mi', '', '-- None --', 1);
g_form.addOption('u_business_disruption_mi', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_mi', '2', 'Second Lowest', 300);
g_form.addOption('u_business_disruption_mi', '1', 'Lowest', 400);
//Transfer
g_form.addOption('u_business_disruption_tr', '', '-- None --', 1);
g_form.addOption('u_business_disruption_tr', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_tr', '2', 'Second Lowest', 300);
g_form.addOption('u_business_disruption_tr', '1', 'Lowest', 400);
//Accept
g_form.addOption('u_business_disruption_ac', '', '-- None --', 1);
g_form.addOption('u_business_disruption_ac', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_ac', '2', 'Second Lowest', 300);
g_form.addOption('u_business_disruption_ac', '1', 'Lowest', 400);
}
if (newValue == 2) {
//Mitigate
g_form.addOption('u_business_disruption_mi', '', '-- None --', 1);
g_form.addOption('u_business_disruption_mi', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_mi', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_mi', '1', 'Lowest', 400);
//Transfer
g_form.addOption('u_business_disruption_tr', '', '-- None --', 1);
g_form.addOption('u_business_disruption_tr', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_tr', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_tr', '1', 'Lowest', 400);
//Accept
g_form.addOption('u_business_disruption_ac', '', '-- None --', 1);
g_form.addOption('u_business_disruption_ac', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_ac', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_ac', '1', 'Lowest', 400);
}
if (newValue == 1) {
//Mitigate
g_form.addOption('u_business_disruption_mi', '', '-- None --', 1);
g_form.addOption('u_business_disruption_mi', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_mi', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_mi', '2', 'Second Lowest', 300);
//Transfer
g_form.addOption('u_business_disruption_tr', '', '-- None --', 1);
g_form.addOption('u_business_disruption_tr', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_tr', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_tr', '2', 'Second Lowest', 300);
//Accept
g_form.addOption('u_business_disruption_ac', '', '-- None --', 1);
g_form.addOption('u_business_disruption_ac', '4', 'Highest', 100);
g_form.addOption('u_business_disruption_ac', '3', 'Second Highest', 200);
g_form.addOption('u_business_disruption_ac', '2', 'Second Lowest', 300);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 11:58 AM
I would still use an onChange client script, but I would do something like:
var avoidMatch = newValue == g_form.getValue('avoid');
var transferMatch = newValue == g_form.getValue('transfer');
var acceptMatch = newValue == g_form.getValue('accept);
if(avoidMatch || transferMatch || acceptMatch){
g_form.clearValue('mitigate');
g_form.showFieldMessage('mitigate','You cannot select the same option twice.','error');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 05:26 AM
You're welcome! Thanks for catching that typo!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 11:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 02:05 PM
Thank you for responding to my question. I ended up going with @Kristen Ankeny 's recommendation, but I appreciate the input.