How can i make incident fields read only if state is closed in Agent Workspace?

kalakaramad_20
Tera Contributor

function onLoad() {

//Type appropriate comment here, and begin script below

var fields = g_form.getEditableFields();
alert(fields);
if(g_form.getValue("state",'closed')) {

for (var x = 0; x < fields.length; x++) {

g_form.setReadOnly(fields[x], true);
} } }

 

 

 

USED THIS SCRIPT | BUT NOT WORKING

19 REPLIES 19

There might be table.* And table.field_name ACLs present before. So do adjust the ACLs if present with role and the state condition 

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@kalakaramad_20 do you wamt it just for agent workspace or all views. If  you want for all views ACL will work fine as suggested by @jaheerhattiwale . Share screenshot of your ACL if possible.


Raghav
MVP 2023
LinkedIn

kalakaramad_20
Tera Contributor

kalakaramad_20_0-1671453078947.png

Done in client script but its not working.

state is closed But the Fields are editable.

 

 

jaheerhattiwale
Mega Sage
Mega Sage

@kalakaramad_20 if you want to try with client script then update the script as below

 

var fields = g_form.getEditableFields();
alert(fields);
if(g_form.getValue("state") == 'closed') {

for (var x = 0; x < fields.length; x++) {

g_form.setReadOnly(fields[x], true);
} } }

 

 

Please check if closed state value is closed or anything else

 

Please mark as correct answer based on impact

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

No Impact Sir