Help in Client Script: If user belongs to CMDB assignment group, he can edit a field in cmdb table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 10:48 AM
Hi team,
Please help me with a client script on cmdb_ci_hardware table:
If a user belongs to cmdb_ci_hardware table, he should be able to edit the new field "External IP". I've written the below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 02:57 AM
I have shared 2 approaches, 1st is ACL based (recommended) and 2nd is using onLoad client script + Display business rule
Please check the same below
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-09-2025 02:45 AM
2 Approaches
1) Field level WRITE ACL, use advanced script
answer = gs.getUser().isMemberOf('Group ABC');
2) you can use onLoad client script + Display business rule on "cmdb_ci_hardware" to check if user belongs to particular group or not
Display business rule
(function executeRule(current, previous /*null when async*/ ) {
// Pass the result to g_scratchpad
g_scratchpad.canEditExternalIP = gs.getUser().isMemberOf('Group ABC');
})(current, previous);
onLoad client script
function onLoad() {
// Check if g_scratchpad indicates permission to edit External IP
if (g_scratchpad.canEditExternalIP) {
g_form.setReadOnly('external_ip', false); // Enable editing
} else {
g_form.setReadOnly('external_ip', true); // Disable editing
}
}
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-09-2025 03:54 AM
Thanks a lot Ankur, I'll go online in few minutes and will update after trying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 03:57 AM
Sure do keep me updated !
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader