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

RaghavSh
Kilo Patron

Create UI policy instead, with condition "state is closed" and view and workspace( if required for obly agent workspace view).

 

I think g_form.getEditableFields(); is causing issue in workspace view.

When you uncheck "Global", you get an option to add view, you cam select workspace there to make your UI policy run on agent workspace only:

Screenshot 2022-12-19 at 4.28.39 PM.png

 


Raghav
MVP 2023
LinkedIn

Hello Done This But the Ui Policy Action What to do over there, I need to make all fields read only when state gets closed.

jaheerhattiwale
Mega Sage
Mega Sage

@kalakaramad_20 You can create a write ACL on incident table and add the condition state is closed.

 

Please mark as correct answer if this solves your issue.

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

Created An ACL but Still not working for the same.