Remove choice field when a specific value selected in a reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 08:29 PM
Hi All,
When service field in change form is selected as "SAP Enterprise Services" remove choice "low" from Risk field except this addback the choice "low" to the Risk field for other values of service field.
I have tried the below onchange clientscript but did not get the desired result :-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 08:31 PM
Hi @1_DipikaD
Looks like you missed to put sys_id in quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 09:04 PM
it's not recommended to use hard-coded sysId so please use GlideAjax
For the current script update as this
I have tried the below onchange clientscript but did not get the desired result :-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var service = g_form.getValue('business_service');
var choice = 'risk';
if(service == '26da329f0a0a0bb400f69d8159bc753d){
g_form.removeOption(choice,'4');
}
//Type appropriate comment here, and begin script below
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 09:21 PM
@Ankur Bawiskar Yes, you are right. But what should be the correct approach to use glideajax .
I have tried the below script in PDI, it's working but in real instance I am not getting the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 09:24 PM
yes use GlideAjax, store the sysId in system property and then compare
what debugging did you perform in your actual instance?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader