- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:48 AM
Hi I have added new choices for On Hold Reason
1. awaiting delivery
2. awaiting payment
3. awaiting contractor
and I want them to be visible only when the category is facilities and should be hidden for other categories.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 08:54 AM - edited 11-30-2023 09:47 AM
I was able to achieve this on my PDI for both scenarios.
1. Wrote down a onChange client script on Category field & put following code into it
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
if (isLoading && oldValue != 'inquiry') { ///update with backend value of Facilities choice here
g_form.removeOption('hold_reason', '1'); //update with backend value of choices which you don't want to see on other categories
g_form.removeOption('hold_reason', '5');
return;
}
if (newValue === 'inquiry') { //update with backend value of Facilities choice here
g_form.addOption('hold_reason', '1', 'Awaiting Caller'); //update the backend & front-end labels here which you only want to see in facilities category
g_form.addOption('hold_reason', '5', 'Awaiting Change');
return;
}
g_form.removeOption('hold_reason', '1');
g_form.removeOption('hold_reason', '5');
}
2. Do make sure you update the backend values & front-end values of the choices.
3. In my scenario, I am hiding choices on all other categories apart from 'Inquiry' category. It should work.
Do mark this response as CORRECT / HELPFUL as it will help others & will motivate me as well to write more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:53 AM - edited 11-30-2023 08:09 AM
Assuming you are talking about the 'On Hold Reason' & 'Category' fields on Incident table & you have already added the Choices to 'On Hold Reason' dictionary, you can write down a onLoad client script on Incident table while refering to following code -
var cat = g_form.getValue('category');
if(cat!='facilities') //make sure to use the backend value of facilities choice, not the label only
{
g_form.removeOption('hold_reason','awaiting_delivery'); //make sure to use backend values of onHoldReason choices as well here
g_form.removeOption('hold_reason','awaiting_payment');
g_form.removeOption('hold_reason','awaiting_delivery');
}
Refer to below article as well for understanding how removeOption function works. This is assuming you are trying to hide only on onLoad. If it is onChange of Category, Refer to Timi's code.
Do mark this as HELPFUL / CORRECT appropriately.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 08:15 AM
Not working HSB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 08:35 AM
Do you want this to work onLoad of your form or whenever you change the Category to a particular value? If you clear the scenario, I can build it on my own PDI & share exact script. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 08:36 AM
its like both