How to restrict integration user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi All
I need someone help in my requirement. My requirement is, If a sc_task state is either "Open, Pending or Work in progress" and at the same time if the "requested for" active status changes to "false" then I need to update the sc_task state to "Pending Cancellation". For this I have written a "After" business rule on "Update" in the "sys_user" table. The problem I am facing is, there are few integration user which is running on user table but they are not updating the "Active" value to "false". Still my BR is getting triggered and it is updating the sc_task state to "Pending Cancellation".
Please help to fix this issue. I am not able to find the root cause for the same. I have shared my script below.
Table: sys_user
BR: After and On Update
Filter Condition: Active changes to False.
Script:
if (previous.active == true && current.active == false) {
var userSysId = current.sys_id;
cancelCatalogTasks(userSysId);
}
function cancelCatalogTasks(userSysId) {
var catalogTaskGr = new GlideRecord('sc_task');
catalogTaskGr.addQuery('cat_item', '57be3d29b7121010189e22b5de11a937');
catalogTaskGr.addQuery('requested_for', userSysId);
catalogTaskGr.addQuery('state', 'IN', [1, 2, -5]);
catalogTaskGr.query();
while (catalogTaskGr.next()) {
catalogTaskGr.state = -6;
catalogTaskGr.work_notes = 'Reason for escalation: User is inactive.';
catalogTaskGr.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Prasnajeet1 ,
Can you please explain more about your issue, i'm not getting it.
if i'm not wrong you want to exclude this script for integration user?
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
my issue is whenever any update is happening in user table via the integration user, even without matching the filter condition still business is triggering and it is updating the sc_task state value. Ideal if condition matched then only BR should triggering but in this case it triggering without matching the filter condition.
My filter condition is if active changes to false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @Prasnajeet1
You can add some logic to avoid it like this-
// Skip if user has integration role
if (current.hasRole('integration_user') || current.hasRole('integration_admin')) {
return;
}
if (current.active.changesTo(false)) {
cancelCatalogTasks(current.sys_id);
}
if my response is helpful please mark as helpful and accept the solution
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
44m ago
any idea like to how to put wait for condition. I don't to run the BR immediately when the condition matched. It should wait for 5min something and then triggered. Can we do like this.