If state is 'closed' then make all the fields read-only for all the users except 'admin'.how to achieve the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 05:02 AM
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,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 05:08 AM
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!!!
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 05:44 AM
Sorry it is not working.....
Can you elaborate the solution please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 05:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 05:18 AM
Can we achieve the same thing by using ACL if Yes, please let me know the steps for the same.