Group Approval from business rule

keshav77
Tera Contributor

Hi All,

 

How I can trigger group approval form business rule if record in some particular state.

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@keshav77 

you can use flow designer with proper trigger condition and then use "Ask for Approval" flow action.

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

View solution in original post

@keshav77 

Thank you for marking my response as helpful.

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@keshav77 

you can use flow designer with proper trigger condition and then use "Ask for Approval" flow action.

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

@keshav77 

Thank you for marking my response as helpful.

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

Bhimashankar H
Mega Sage

Hi @keshav77 ,

 

As suggested by @Ankur Bawiskar  it is best practice to trigger the approval. But you want to trigger from business rule then you need to write some code. It will create a new record in 'sysapproval_approver'  table.

Below is for to trigger approval to specific group.

(function executeRule(current, previous /*null when async*/) {
   //Check the state of record or else you can have this condition in your business rule filter condition.
    if (current.state == 'assess') { 
        var groupSysId = 'YOUR_GROUP_SYS_ID'; // Replace with the sys_id of the approval group
        var approvalGr = new GlideRecord('sysapproval_approver');
        
        var groupMembers = new GlideRecord('sys_user_grmember');
        groupMembers.addQuery('group', groupSysId);
        groupMembers.query();
        
        // Create approval records for each group member that's why need to create new record for each
        while (groupMembers.next()) {
            approvalGr.initialize();
            approvalGr.sysapproval = current.sys_id; // Link to the current record
            approvalGr.approver = groupMembers.user.sys_id; // Set the approver
            approvalGr.state = 'requested'; // Set approval state
            approvalGr.insert();
        }
    }
})(current, previous);

 

This way you can trigger the group approval from BR.

 

Thanks,

Bhimashankar 

----------------------------------------------------------------------------------------
Please mark my answer as helpful/correct if it resolves your query.
----------------------------------------------------------------------------------------

Bhimashankar H
Mega Sage

Hey @keshav77 ,


If my answer helps you or resolves your query, please consider marking as 'Accept as Solution'.  So other readers with similar questions can find it easily.

Thanks,
Bhimashankar H