Prevent an admin from specific deletions in background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello,
is it possible to prevent background script deletion of only a specific table like sys_user for admin users?
So, for example:
We want to prevent, that users with admin role cannot execute deletion on the sys_user table.
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Use "Before" Business Rule
- Go to System Definition → Business Rules.
- Click New.
- Configure like this:
- Name: Prevent sys_user deletion for admins
- Table: sys_user
- Advanced: Checked
- When: Before
- Insert/Update: Unchecked
- Delete: Checked
- Condition: (Optional) – Only for admin role users:
gs.hasRole('admin');
- Script:
(function executeRule(current, previous /*null when async*/) {
if (gs.hasRole('admin')) {
gs.addErrorMessage("Admins are not allowed to delete users!");
current.setAbortAction(true); // Prevent deletion
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello @Anton42 ,
Yes this is possible via before delete business rule :
If my response helps you then mark it as helpful and accept as solution.
Regards,
Aditya,
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
this will stop admin from deleting user from list or form as well
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello @Ankur Bawiskar ,
yes it will stop admin from deleting user from list or form as well 🙂.
how can we restrict deletion operation only for background script ?
