- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:14 AM
did you check what came in alert?
I believe your onchange is written on department variable
Are you sure the platform name is correct and the sap choice value is correct? Any spaces in the choice value?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var st = g_form.getValue("department");
if (st == "5d7f17f03710200044e0bfc8bcbe5d43")
{
alert('inside if');
g_form.setValue("platform", 'sap');
}
//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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 07:20 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 12:48 AM
Hi @1_DipikaD ,
Can you please try below code?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') { // change '===' to '=='
return;
}
if ( g_form.getValue("department") == "5d7f17f03710200044e0bfc8bcbe5d43") // change '===' to '=='
{
g_form.setValue("platform", '8'); //set the values
}
//Type appropriate comment here, and begin script below
}
If my response finds helpful, please indicate its helpfulness by selecting Accept as Solution and Helpful.
Thanks,
Vaibhav Nikam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:05 AM
I correct the script it's working fine.
But drop down value is not changing while I am changing the reference field value , it remains the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:08 AM
Can you please check and share the backend name of dropdown field and the value you are setting?
If my response finds helpful, please indicate its helpfulness by selecting Accept as Solution and Helpful.
Thanks,
Vaibhav Nikam