- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2021 11:44 PM
Hi Team,
Having a requirement to write a ACL to allow only members of a particular group to edit three user defined fields in location table. Kindly suggest.
Regards,
Kayathri
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2021 08:18 AM
Hi,
so members of that group should be allowed editing only 3 fields
All others should be readonly
Do this
Display BR on your table:
g_scratchpad.isMember = gs.getUser().isMemberOf('Group Name');
onLoad Client Script:
function onLoad(){
if(g_scratchpad.isMember.toString() == 'true'){
// make all fields readonly
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
// make those 3 fields as editable
g_form.setReadOnly('fieldA', false);
g_form.setReadOnly('fieldB', false);
g_form.setReadOnly('fieldC', false);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2021 11:49 PM
Hi,
You need to create a Write ACL for the table_name.field_name. SO you need to create three ACL's for three fields.
In your ACL script you can check gs.isMemberOf('GroupName/Sys_id') to check whether user is member of particular group.
If user is member of group set answer=true else answer=false
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2021 11:57 PM
As mentioned by Anil you can use 3 field level WRITE ACLs on individual fields.
OR
If you don't want to create 3 ACLs then you can take Display BR + Client Script approach
Display BR: it would check if logged in user is member of particular group and store in g_scratchpad
onLoad Client Script: it would get the scratchpad variable value and based on true/false allow edit of those 3 fields on form
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2021 08:01 AM
Hi Ankur,
I have the requirement that the three fields should be editable by the members of the particular group, so I have written a table level ACL to make that edit all the fields,3 field level ACLs also written, since only the members of those group should access those 3 fields, not other members. now I want to restrict the group members to edit only the three fields. Please suggest how it can be done.
Regards,
Kayathri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2021 08:18 AM
Hi,
so members of that group should be allowed editing only 3 fields
All others should be readonly
Do this
Display BR on your table:
g_scratchpad.isMember = gs.getUser().isMemberOf('Group Name');
onLoad Client Script:
function onLoad(){
if(g_scratchpad.isMember.toString() == 'true'){
// make all fields readonly
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
// make those 3 fields as editable
g_form.setReadOnly('fieldA', false);
g_form.setReadOnly('fieldB', false);
g_form.setReadOnly('fieldC', false);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader