The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to restrict integration user

Prasnajeet1
Giga Guru

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);

7 REPLIES 7

palanikumar
Giga Sage

I'm not sure why is this happening to integration users.

If you want to avoid running this BR for Integration Users then you can add the below condition:

Make sure this flag is set for Integration User. If not then you can add any naming convention or any field like SSO source that differentiate Integration User from regular user
 
Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

@Prasnajeet1 

if the above BR is not getting triggered then any other logic is updating SC Task?

what debugging did you do?

Did you try disabling this BR and confirm the issue?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

BR is triggering, problem is why it is triggering when the condition is not matched.