cLient script not working here i wrote script to make readonly when ticket moved to closed state.

RAJPRAVEENR
Giga Contributor
function onLoad() {
    var st = g_form.getvalue('state');
    if (st == 7) {

        var fields = g_form.getEditableFields();
        for (var x = 0; x < fields.length; x++) {
            g_form.setReadOnly(fields[x], true);
        }
    }
10 REPLIES 10

Bhuvan
Kilo Patron

@RAJPRAVEENR 

 

I would recommend not to create Client Script like this to achieve your function. There is an out of box ACL that restricts editing of a record when state is 'Closed' or 'Cancelled' for users with 'itil' role. You can update or create similar ACL and extend to roles that needs to be limited with read-only permissions.

 

https://<instance-name>.service-now.com/sys_security_acl.do?sys_id=66ec26370a0a0b0100a67b597d415b84&...

 

If this helped to answer your query, please accept the solution and close the thread.

 

Thanks,

Bhuvan

@RAJPRAVEENR 

 

Did you get a chance to review the proposed solution ?

 

If my response helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

I am unable to use that link.. why this script is not working i can see in video they use same script it working for them

Shashank_Jain
Kilo Sage

@RAJPRAVEENR ,

 

Try this!

function onLoad() {
    var st = g_form.getValue('state');
    if (st.toString() == '7') {    
        g_form.disable();
    }
}
If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

No Not working 

RAJPRAVEENR_0-1755947176120.pngRAJPRAVEENR_1-1755947352102.png