- 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 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 09:42 AM - edited 11-30-2023 09:42 AM
It is working and is there a chance to set their sequence as well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 09:46 AM
g_form.addOption('field'_name, '1', 'Awaiting Info', 1); //add the order in the last parameter like 1,2,3,4 while adding these
g_form.addOption('field_name', '5, 'Awaiting Change', 2); //add number at the end at whatever position you want to add these.
Mark this response as CORRECT if it completes your requirement. Will help others & definitely motivate me to write more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:59 AM - edited 11-30-2023 08:04 AM
You can define an OnChange Client Script on the Category field, in order to manage both when the form load and when the Category changes.
UI Type: All
Type: OnChange
Field: Category
Sample script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === 'facilities') {
g_form.addOption('hold_reason', 'Awating Delivery', 'awaiting delivery');
g_form.addOption('hold_reason', 'Awating Delivery', 'awaiting payment');
g_form.addOption('hold_reason', 'Awating Delivery', 'awaiting contractor');
return;
}
g_form.clearValue('hold_reason');
g_form.removeOption('hold_reason', 'awaiting delivery');
g_form.removeOption('hold_reason', 'awaiting payment');
g_form.removeOption('hold_reason', 'awaiting contractor');
}
If the On Hold Reason field is not always visible and depends on the State field, you may also need to consider to have another OnChange Client Script on the State field as well.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 08:37 AM
if we use clearoption will not be cleared all the other options as well? timi