Client Script Error - Change model: Mandatory Fields - After Zurich upgrade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi team,
I'm facing this error after the Zurich upgrade on the Change request form "onChange script error: TypeError: g_scratchpad.change_model.refreshMandatoryFields is not a function function () { [native code] }"
This is the Client Script that I'm using:
Kindly suggest any solutions to fix this please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I ran into the same issue after upgrading to Zurich:
onChange script error: TypeError: g_scratchpad.change_model.refreshMandatoryFields is not a function
It turns out that the g_scratchpad.change_model.refreshMandatoryFields() function was removed or changed in Zurich, so any client script calling it will fail.
Here’s the updated working script that fixed the problem for me:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === oldValue) {
return;
}
// Update mandatory fields based on selected Change Model
if (newValue === 'standard') {
g_form.setMandatory('justification', false);
g_form.setMandatory('risk_assessment', false);
} else {
g_form.setMandatory('justification', true);
g_form.setMandatory('risk_assessment', true);
}
// Removed deprecated call:
// g_scratchpad.change_model.refreshMandatoryFields();
}
After removing the deprecated line and handling the mandatory logic manually, the error disappeared.
Hope this helps others who face the same issue after the upgrade!
✅ Please like if this answer solves your problem. 👍
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I encountered the same issue after upgrading to Zurich:
This happens because g_scratchpad.change_model.refreshMandatoryFields() was removed or changed in the Zurich release.
Here’s the updated client script that resolved the issue for me:
After removing the deprecated line and managing the mandatory logic manually, the error stopped appearing.
Hope this helps anyone facing the same issue after the Zurich upgrade.
If this works for you, please give it a like!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@Manigandan24 , Can you unchecked the 'isolate script' field on client script and test.
Thanks & Regards,
Muhammad Iftikhar
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@Manigandan24, I tested it on a Zurich release PDI, and the OOTB client script worked perfectly fine. You might want to check if your team has made any customisation to the OOTB configuration earlier. If everything looks standard, consider raising a ticket with ServiceNow for further investigation.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.