If state is 'closed' then make all the fields read-only for all the users except 'admin'.how to achieve the same

Veera raju
Tera Expert

Hi,

Can any one help me on the below query:

If state is 'closed' then make all the fields read-only for all the users except 'admin'.how to achieve the same.

Thanks in advance,

7 REPLIES 7

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Something like below could already fit. Though your actual question could be a lot harder. Who already has access/hasn't? Do you want this onChange or just onLoad? Are there already other write ACL's in place, etc., etc..

So see the below screenshot as an idea what you partly could add / play around with. It's not a solid solution which you can copy 1:1!!!

find_real_file.png

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Sorry it is not working.....

 

Can you elaborate the solution please.

Viraj Hudlikar
Giga Sage

Write On Load client script which will make all fields of that table to read only.

function onLoad() {


 //Type appropriate comment here, and begin script below


var prb_state=g_form.getValue('state');


if(prb_state =='4')                                                               //Replace 4 with your Close Choice Value

{

   var fields = g_form.getEditableFields();


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

   if(g_user.hasRole('admin')){
     g_form.setReadOnly(fields[x], true);
    }

   }


   }


}

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact. 


Thanks & Regards, 
Viraj Hudlikar.

Can we achieve the same thing by using ACL if Yes, please let me know the steps for the same.