- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2025 10:18 PM
I want to make a field read only for non admin roles on incident form.
Can any one explain step by step procedure and if script required please help me with that.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 09:05 PM
Hi @yaddanki
You need to craete "On load" client script to acheive this.
PFB sample. to make the date field read-only for non-admin users.
Client script:
function onLoad() {
if (!g_user.hasRole('admin')) {
g_form.setReadOnly('<FIELD NAME>', true); //REPLACE THE <FIELD NAME> WITH THE ACTUAL FIELD
} else {
g_form.setReadOnly('<FIELD NAME>', false); //REPLACE THE <FIELD NAME> WITH THE ACTUAL FIELD
}
}
Non-Admin user view:
Admin user view:
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 09:33 PM
2 approaches
1) simply create a field level WRITE ACL
Give "admin" in roles section
OR
2) you cannot use UI policy for this, please use onLoad client script on incident table
function onLoad() {
if (!g_user.hasRoleExactly('admin')) {
g_form.setReadOnly('fieldName', true);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 09:05 PM
Hi @yaddanki
You need to craete "On load" client script to acheive this.
PFB sample. to make the date field read-only for non-admin users.
Client script:
function onLoad() {
if (!g_user.hasRole('admin')) {
g_form.setReadOnly('<FIELD NAME>', true); //REPLACE THE <FIELD NAME> WITH THE ACTUAL FIELD
} else {
g_form.setReadOnly('<FIELD NAME>', false); //REPLACE THE <FIELD NAME> WITH THE ACTUAL FIELD
}
}
Non-Admin user view:
Admin user view:
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 09:33 PM
2 approaches
1) simply create a field level WRITE ACL
Give "admin" in roles section
OR
2) you cannot use UI policy for this, please use onLoad client script on incident table
function onLoad() {
if (!g_user.hasRoleExactly('admin')) {
g_form.setReadOnly('fieldName', true);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader