Set mandatory using on change client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 05:43 AM - edited 01-07-2024 05:55 AM
Hi,
I am trying to write on change client script, so that if "state" field changes directly from "new" (1) to any other status except "in progress" (2), assigned to field will be mandatory on SOW.
I tried this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 05:50 AM
Hi @Sahar_Kaizer ,
Try making the following modification in your script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (oldValue == '1' && newValue != '2') {
g_form.setMandatory('assigned_to', true);
} else {
g_form.setMandatory('assigned_to', false);
}
}
If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 05:54 AM
Thanks but it didnt work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 06:22 AM
Try like this
if (oldValue.toString().indexOf("1") > -1 && newValue.toString().indexOf("2") < 0) {
g_form.setMandatory('assigned_to', true);
} else {
g_form.setMandatory('assigned_to', false);
}
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 06:24 AM
also doesnt work