Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

When State is Closed. Make all fields ReadOnly

maheshtallu
Tera Contributor

maheshtallu_0-1763618935754.png



when i execute above why remaining all fields not changed to ReadOnly ?

1 REPLY 1

k_lutz
Tera Guru

Hi,

It's hard to say for sure without seeing the whole screen but just on the screen there are several things:

 

1) The screenshot shows this is inactive. You may have turned it off while testing. Make sure it is active.

2) I would make sure the "isolate script" is unchecked.

3) You may want to try it similar to an existing script to follow what SN does. I found this one on another table that SN is doing something similar for an onChange client script:

 

    var state = g_form.getValue('error_status');
    if (state === 'fixed' || state === 'ignored' || state === 'reviewed') {
        var fields = g_form.getEditableFields();
        for (var x = 0; x < fields.length; x++) {
            g_form.setMandatory(fields[x], false);
            g_form.setReadOnly(fields[x], true);
        }
    }