OnChange Client Script not working

Edxavier Robert
Mega Sage

We have a OnChange client script on the Incident table that sets the Additional comments mandatory when the Incident is in state Cancelled. This script should prevent canceling the incident if the additional comments are empty. It was working before the upgrade to Tokyo.

If I change the state from any state to Canceled doesn't work, but after selecting the canceled state and changed back to any other state and then changed back again to canceled it works. But not when is first selected. 
If I enable the field watcher on the state field it works, but after disabling it, it doesn't work again.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Type appropriate comment here, and begin script below

    if (newValue == '8') {
        g_form.setMandatory("comments", true);
    } else {
        g_form.setMandatory("comments", false);
    }
}

 

1 ACCEPTED SOLUTION

Steven Parker
Giga Sage

The UI Policy on the Incident table "Make the field 'Additional Comments' mandatory when the On Hold Reason is 'Awaiting Caller'" is conflicting with your client script.

 

Here in my Personal Dev instance, I have disabled that UI Policy and your script is working correctly.

StevenParker_0-1683227294223.png

 

The easiest solution is disable your client script and update the UI Policy by using the "Add OR Clause" button to add an Or condition to this UI policy and state "OR - State is Canceled" like below:

StevenParker_1-1683227445614.png

 

The other solution is to disable the UI Policy and use your Client Script.


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

View solution in original post

7 REPLIES 7

Ian Mildon
Tera Guru

You should be able to just remove the ' ' around the 8 as it is not a string, it's a value

Hi Ian, removing the "" didn't work. Still having the same experience. 

Steven Parker
Giga Sage

The UI Policy on the Incident table "Make the field 'Additional Comments' mandatory when the On Hold Reason is 'Awaiting Caller'" is conflicting with your client script.

 

Here in my Personal Dev instance, I have disabled that UI Policy and your script is working correctly.

StevenParker_0-1683227294223.png

 

The easiest solution is disable your client script and update the UI Policy by using the "Add OR Clause" button to add an Or condition to this UI policy and state "OR - State is Canceled" like below:

StevenParker_1-1683227445614.png

 

The other solution is to disable the UI Policy and use your Client Script.


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven