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

Task getting update from integration user

PrasnajeetJ
Mega Contributor

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);
        cancelRefreshLineTasks(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);
1 REPLY 1

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