The CreatorCon Call for Content is officially open! Get started here.

Configuring the Ask for Approval Flow designer action to not trigger to the user if user is a member

Madhan007
Tera Contributor

Hi Everyone,

We have a flow attached to the Catalog Item. I need to trigger a Group approval in the flow using the Ask for Approval flow action, but the approval should not be triggered to a  user if the user is the requestor and a member of the approval group.

Please pour your Insights

Thank you!

4 REPLIES 4

dbook
Kilo Sage

Use a business rule or flow to set the user in scope as 'No Longer Required'. 

 

This will stop the user from approving but keep the group approval record open. 

Ankur Bawiskar
Tera Patron
Tera Patron

@Madhan007 

You can't tell "Ask for Approval" flow action to not include a particular member from group.

you can use before insert business rule on sysapproval_approver table to ignore the insert if your condition matches

BR: Before Insert on sysapproval_approver

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var ritmSysId = current.sysapproval;
    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("sys_id", ritmSysId);
    gr.addQuery('cat_item.name', 'Your Item Name'); // give your catalog item name here
    gr.query();
    if (gr.next()) {
        var requester = gr.request.requested_for.toString();
        if (current.approver.toString() == requester || gs.getUser().getUserByID(requester).isMemberOf(current.group.toString()))
            current.setAbortAction(true);
    }


})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Madhan007 

another way is to use scripted flow approval and get all the group members and don't add that member if member is requester of that RITM

Scripted Approvals in Flow Designer with Flow Variables 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Madhan007 

Thank you for marking my response as helpful.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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