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

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Can you check if there is any other client script conflicting. Also, can you try adding alerts for a check to understand the behaviour on multiple changes.

Hi, I just create the alert and its recognizing the state change to Canceled. 

EdxavierRobert_0-1683227659950.png

 

Prince Arora
Tera Sage
Tera Sage

@Edxavier Robert ,

 

Ideally this shouldn't happen,

Can you delete the previous client script and create a new one with the same script and try again!

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Hi Prince, removing the client script and creating that again didn't work.