Update Group Manager and Automate Approver Reassignment via Business Rule

Deepika Desai
Tera Contributor

Hello All,

is this possible if we change group manager as A to B. new approvals are automatically reassigned to group manager B via a business rule in servicenow? if yes how can we achevie this?

2 REPLIES 2

Chaitanya ILCR
Kilo Patron

Hi @Deepika Desai ,

 

If you are logic is asking for group manager approval 

You don't have to do anything the approval will automatically go to the new manager 

You just have to change the manager 

 

 

Regards 

Chaitanya 

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepika Desai 

yes whatever approvals are generated after manager change, those will be sent to new managers.

If any in-flight approvals are pending for older manager A then you need to write some custom logic to update them to Manager B.

You can use after update business rule on sys_user_group

Condition: Manager Changes

Script: Something like this but please enhance

(function executeRule(current, previous /*null when async*/) {
    // Only proceed if the manager has changed
    if (current.manager.changes()) {
        var oldManager = previous.manager;
        var newManager = current.manager;

        // Find all open approvals for this group assigned to the old manager
        var grApproval = new GlideRecord('sysapproval_approver');
        grApproval.addQuery('approver', oldManager);
        grApproval.addQuery('state', 'requested'); // Only open approvals
        grApproval.addQuery('assignment_group', current.sys_id); // If you track group on approval
        grApproval.query();

        while (grApproval.next()) {
            grApproval.approver = newManager;
            grApproval.update();
        }
    }
})(current, previous);

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