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.

How to make all fields readonly on the incident form for Cancelled state?

Bharath kumar6
Tera Expert

When the state changes to cancelled - for all the itil users -- all the fields should be readonly.

1 ACCEPTED SOLUTION

Chetan Mahajan
Mega Sage

Hi Bharat,

                        Try below code in Onchange Client script on state 

if(g_user.hasRole("itil") && g_form.getValue("state")==8) {
	 var fields = g_form.getEditableFields();
         for (var x = 0; x < fields.length; x++) {
           g_form.setReadOnly(fields[x], true);
         }
	}

View solution in original post

3 REPLIES 3

Chetan Mahajan
Mega Sage

Hi Bharat,

                        Try below code in Onchange Client script on state 

if(g_user.hasRole("itil") && g_form.getValue("state")==8) {
	 var fields = g_form.getEditableFields();
         for (var x = 0; x < fields.length; x++) {
           g_form.setReadOnly(fields[x], true);
         }
	}

Jaspal Singh
Mega Patron
Mega Patron

Ideal option will be to create ACL of type write for each field when state changes to Cancelled for required table & for required ITIL users.

Community Alums
Not applicable

Hi Bharath,

There is an OOTB UI Policy "Make fields read-only on close" which does that. You can go ahead and check that UI Policy.

When a state changes to cancelled or closed all the fields will automatically be read-only.

 

Thanks,

Visakha