The CreatorCon Call for Content is officially open! Get started here.

Client Script Error - Change model: Mandatory Fields - After Zurich upgrade

Manigandan24
Tera Contributor

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] }"

Manigandan24_1-1759825183151.png

This is the Client Script that I'm using:

Manigandan24_2-1759825221812.png

 

Kindly suggest any solutions to fix this please.

9 REPLIES 9

Shivanya Velmur
Tera Contributor

Hi @Manigandan24 

 

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. 👍

Shivanya Velmur
Tera Contributor

 

Hi @Manigandan24 

 

I encountered the same issue after upgrading to Zurich:

 

 
onChange script error: TypeError: g_scratchpad.change_model.refreshMandatoryFields is not a function

 

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:

 

 
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 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!

M Iftikhar
Giga Sage

@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.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Hi @M Iftikhar ,

 

Tried it and facing the same issue.

@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.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.