Hiding Choice Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi All
I have used a Onload client script before to hide "choice" options based on the value of another field, but for some reason I cannot get it to work. The Script is set on the task table as I want it to operate on both Incidents and RITMS.
Our scenerio is we have a field called "Attempted Contact " (u_attempted_contact), which has the following choice options :-
First Attempt
Second Attempt
Third Attempt
Escalated to Regional Coach
We would like to only make the next option in the sequence visble to select, so if you had chosen "First Attempt" and ave the record, if you went back to that field, then the only option to select this time would be "Second Attempt" and so On.
To partially achieve this I have created another field called "Attempted Contact (Current Value)", which stores the value of the "Attempted Contact" after that field has been changed. That way my client script could look up the value of this field and then remove the appropiate options from the "Attempted Contact" field
So an example below, I selected "First Attempt" and save the record, so then "Attempted Contact "Current Value) got auto populated
What I then want to happen is if i then wanted to change the value of the "Attempted Contact" again then it shoudl only display "Second Attempt" as a choice, but it doesn't it displays this:-
Here is my script
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Make sure you are using the choice values in the script, not the Label - for both fields. Add an alert to the script if in doubt. For example, in the out of box Category field, you would use 'inquiry' not 'Inquiry / Help'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
41m ago
Hi @jonathangilbert,
It can be achieved by restricting the options only after the first selection.
On the first load, when no value has been selected yet, all choices remain visible. Once a value is selected and saved, the onLoad client script clears the choices and displays only the next valid option in the sequence.
function onLoad() {
var currentValue = g_form.getValue('u_attempted_contact_current_value');
// First time / no previous selection → show all options
if (!currentValue) {
return;
}
// Restrict options only after a value exists
g_form.clearOptions('u_attempted_contact');
if (currentValue == 'first_attempt') {
g_form.addOption('u_attempted_contact', 'second_attempt', 'Second Attempt');
}
else if (currentValue == 'second_attempt') {
g_form.addOption('u_attempted_contact', 'third_attempt', 'Third Attempt');
}
else if (currentValue == 'third_attempt') {
g_form.addOption('u_attempted_contact', 'escalated', 'Escalated to Regional Coach');
}
}
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.