- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 08:06 AM
I created a form and I want to make one field read-only for the certain roles.
.how to achive this.
ex: i need manager field non-editable for the user who have the these two roles 1. employee manager, 2. project manager.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 08:28 AM
Hello,
Please try this in on load client script
if(g_user.hasRoleExactly('your role name'))
{
g_form.setReadOnly('your field name',true);
}
please mark my response correct if it helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 08:10 AM
Hi Siva,
It can achieved in multiple ways
1. ACL is Best practice check the role make read-only
https://community.servicenow.com/community?id=community_question&sys_id=afe88471dbaf7304feb1a851ca961967
https://community.servicenow.com/community?id=community_question&sys_id=a4302ffcdb43db449d612926ca96192e
Thanks
Chandu Telu
Please Mark ✅ Correct/helpful, if applicable,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 08:16 AM
Hi,
ACL is the recommended approach i.e. field level WRITE ACL on that field of the table
Another way
1) onLoad client script
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-12-2022 08:24 AM
i have written onload client script .but it was not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 08:28 AM
Hello,
Please try this in on load client script
if(g_user.hasRoleExactly('your role name'))
{
g_form.setReadOnly('your field name',true);
}
please mark my response correct if it helped you