Please let me know the correction in the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:31 AM
Hi,
Please let me know the correction in the below script? this script works only if I deactivate the user one by one. But this script didn't work, if I deactivate multiple users at a time into list view(by dragging many user list - then set active is false). Thanks.
Business Rule:
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 09:06 AM
I could see multiple messages in log which says the BR is running for more than 1 record when you are updating from list view
If your BR triggers multiple times based on those number of records selected it means issue is in eventQueue()
in 4th parameter of eventQueue() you should send recipient
Are you sure in your notification you have set Event parm2 contains recipient checkbox?
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
01-21-2025 09:13 AM
why are you using script action to update the CI?
you can directly update within the IF condition for index check
I hope your BR is after update when user is deactivated
var userSysId = current.sys_id.toString();
var approverarray = [];
var index = -1;
var ciname;
var level1approver = new GlideRecord('cmdb_ci');
level1approver.addQuery('u_level_1_approver', 'CONTAINS', userSysId);
level1approver.query();
while (level1approver.next()) {
var approver = level1approver.getValue('u_level_1_approver');
approverarray = approver.split(',');
index = approverarray.indexOf(userSysId);
ciname = level1approver.getValue('name');
if (index > -1) {
approverarray.splice(index, 1);
level1approver.u_level_1_approver = approverarray.toString();
level1approver.update();
}
}
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
01-21-2025 06:51 PM
Hope you are doing good.
Did my reply answer your question?
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
01-21-2025 11:15 PM
Thanks for reply, Initially i created only business rule to remove deactivated users name from CMDB_CI table.
But if i deactivate multiple users into List View(drag and select many users then change active = false), these business rule didnt work.
So that Architect advised to do trigger event to remove disable user.