Ask for Approval action but don't include Submitter

leonard_gilbert
Tera Expert

I have a catalog item that is locked down to a single group via role assignment.  I'm looking for something in the form of two-factor approval for it. Therefore the submitter should not get a vote in the approval flow targeted to the same group if they submit it but should if other members submit instead. Any ideas?

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hello @leonard_gilbert 

So, you exclude the approval to the user if the requester is same of the approval group. If understanding is correct you can use below logic in your Rules script in Ask for Approval action:

var users = [];
var requester = fd_data.trigger.request_item.requested_for; //get the requester for 
var grGrpMem = new GlideRecord("sys_user_grmember");
grGrpMem.addQuery("group", "019ad92ec7230010393d265c95c260dd");  // put your group here
grGrpMem.addQuery("user", requester);
grGrpMem.query();
if(!grGrpMem.hasNext()) {
    return 'ApprovesAnyG[019ad92ec7230010393d265c95c260dd]';  //if submitter is not part of the group
} else { //if submitter is part of the group 
    grGrpMem = new GlideRecord("sys_user_grmember");
    grGrpMem.addQuery("group", "019ad92ec7230010393d265c95c260dd");
    grGrpMem.addQuery("user" , "!=" , requester);  // exclude the requester
    grGrpMem.query();
    while(grGrpMem.next()) {
        users.push(grGrpMem.getValue("user"));
    }
    return 'ApprovesAnyU['+users+']'; //send the approval to remaining users in the group 
}

Hope it helps:)

Thanks,
Murthy

View solution in original post

3 REPLIES 3

Murthy Ch
Giga Sage

Hello @leonard_gilbert 

So, you exclude the approval to the user if the requester is same of the approval group. If understanding is correct you can use below logic in your Rules script in Ask for Approval action:

var users = [];
var requester = fd_data.trigger.request_item.requested_for; //get the requester for 
var grGrpMem = new GlideRecord("sys_user_grmember");
grGrpMem.addQuery("group", "019ad92ec7230010393d265c95c260dd");  // put your group here
grGrpMem.addQuery("user", requester);
grGrpMem.query();
if(!grGrpMem.hasNext()) {
    return 'ApprovesAnyG[019ad92ec7230010393d265c95c260dd]';  //if submitter is not part of the group
} else { //if submitter is part of the group 
    grGrpMem = new GlideRecord("sys_user_grmember");
    grGrpMem.addQuery("group", "019ad92ec7230010393d265c95c260dd");
    grGrpMem.addQuery("user" , "!=" , requester);  // exclude the requester
    grGrpMem.query();
    while(grGrpMem.next()) {
        users.push(grGrpMem.getValue("user"));
    }
    return 'ApprovesAnyU['+users+']'; //send the approval to remaining users in the group 
}

Hope it helps:)

Thanks,
Murthy

This worked perfectly, exactly what I needed. Thanks

Glad to resolve your query! @leonard_gilbert 

Thanks,
Murthy