g_form.setMandatory in client script is not working on the workspace but working in native view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
g_form.setMandatory in client script is not working on the workspace but working in normal view.
OnChange Client script
OnChange Field Name : Account
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
var gId = '1234493d47ba6a507c23de79116d7890';
if (newValue ===gId) {
g_form.setMandatory('service', false);
g_form.setMandatory('subcategory', false);
} else {
g_form.setMandatory('service', true);
g_form.setMandatory('subcategory', true);
}
return;
}
gId = '1234493d47ba6a507c23de79116d7890';
if (newValue ===gId) {
g_form.setMandatory('service', false);
g_form.setMandatory('subcategory', false);
} else {
g_form.setMandatory('service', true);
g_form.setMandatory('subcategory', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
The issue you're facing with your onChange client scripts not working as expected in the workspace could be due to the different behavior of forms and events in the workspace compared to the standard form view.
Please verify with alternative best approach "UI Policy"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hello @Sathwik1 ,
I tried the different scenario in my PDI, and the client script works correctly in Workspace.
It may not work in your PDI due to the following reasons:
Incorrect field or variable ID
Isolate Script option is enabled (disable it and test)
Using === (triple equals), which checks both value and data type
Best Practice:
Instead of scripting, this requirement can be achieved using a UI Policy.
Configuration-based solutions are recommended over scripting whenever possible, as they are easier to maintain and follow platform best practices.
you can refer following attachments :
If this helps you then mark it as helpful and accept as solution😊.
Regards,
Aditya ,
Technical Consultant
