Hi,How do I make one of the section views read only for some people and give write access to the others?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 02:44 AM
Hi,How do I make one of the section views read only for some people and give write access to the others?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 03:04 AM
Hi Jasmine,
Do you want to hide section based on role.
g_form.setSectionDisplay('schedule', false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 03:07 AM
Thanks for the answer Sneha. But no i am not looking for hiding the section.
My requirement is
1)Section X is visible on certain condition(done that)
2)All fileds under X, say 20 fields are read only(done that)
3)These fields should be editable only by certain people.(Need help)
The problem here is ACL is applied on one field at a time.But i need ACL to be applied for multiple fields at a time and make people with certain role have access to edit all these fields in this particular section.The rest of the people will just have it in read only status.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 11:16 PM
Hello Jasmine,
To add, Please refer the below link for more info on how to validate roles at client side i.e g_user.hasRole('PASSROLE NAME');
http://wiki.servicenow.com/index.php?title=GlideUser_(g_user)#hasRole
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setSectionDisplay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 11:54 PM
Hi,
Can you elaborate your requirement? As per my assumption, If you want to Restrict users from Writing to the fields present in a particular section then you can either write a UI Policy or a client script to make it a Read Only field by checking for the User Roles for the logged in User. Please refer the script below for reference:
Script:
On Load Client Script on the Desired Table say for Example on Incident Table:
function onLoad() {
//Type appropriate comment here, and begin script below
var logged_user = g_user.hasRole('itil'); //Replace your Role for which you want to check here
if(logged_user)
{
g_form.setReadOnly('field_name',false); //Replace your Field name here
}
else
{
g_form.setReadOnly('field_name',true); //Replace your Field name here
}
}
In case if you want to hide Section for uses with particular Role then you can use the Code snippet provided by Sneha above in an On Load Client Script as below:
function onLoad() {
//Type appropriate comment here, and begin script below
var logged_user = g_user.hasRole('itil');
if(logged_user)
{
g_form.setSectionDisplay('section_name',true);
}
else
{
g_form.setSectionDisplay('section_name',false); //Make Sure the Section Name is in Small Case letters
}
}
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke