OnChange client script in Incident table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 03:58 AM
Hi,
I've found a weird behavior with our OnChange client scripts that targets the Incident Table. We have a simple script that removes the mandatory status of the Assigned To field (which is set by a UI Policy) when the Assignment Group changes, so it can be left empty, but this doesn't work. We have exactly the same situation for the RITMs and it works perfect there.
Then, checking if some other client script or UI Policy is interfering I found that there is an OOTB script in the same situation. Does anyone have any idea of why this may be happening? It looks like it just doesn't detect the change in the field and the client script does not trigger.
The script that doesn't work:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue != oldValue)
g_form.setMandatory('assigned_to',false);
}
The UI Policy that sets the field mandatory is just based on this condition:
The OOTB script that also does not work is named "Empty assigned_to on group change"
Thanks a lot in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 04:58 AM
Hi @Miguel_M ,
Hope you are doing well.
UI Policies execute after Client Scripts. If there is conflicting logic between a Client Script and a UI Policy, the UI Policy logic applies.
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 12:51 AM
Hi @Harshal Aditya, I know but in this case, as the OnChange scripts applies when a field changes before reloading the form, I though it should override the UI Policy until the form is loaded again (at least it's how it seems to be working in the requested items).
I've also tried to remove the policy and do the opposite (the onchange script to make the field mandatory) and it doesn't applies neither, so I still suspect that even if it shouldn't work due to the logic, there is something wrong.
Thanks a lot anyway!
Regards,
Miguel