Trigger only one approval request if manager and group owner is same person

2022_ServiceNow
Tera Expert

Hi,

I have a requirement the workflow.

 

I have worked on this workflow. If the user's manager and the group owner are the same or different person, it is triggering two approval requests.

But, in the catalog form, if the user's manager and the group owner are the same person, it should trigger only one approval request. How can I achieve this?

Thank you in advance.

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hello,

In the workflow, you'd need to evaluate the user's manager and the group owner...using an if activity in workflow or if logic in flow designer and then if yes/true, request approval, otherwise, move on and do the next thing in the process.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

To do that, I need to get the value from the catalog form for the variable Group Owner and then check for condition whether Manager == group owner. I'm struggling in the scripting part. Can you please help me with it?

answer = skipApproval();

function skipApproval() {

    var requested_for = current.variable_pool.requested_for_v1.getValue();
    var sg_owner = current.variable_pool.v_ichs_sg_group_owner1.getValue();
    var user = new GlideRecord("sys_user");
    user.get(requested_for);
    if (user.manager == current.v_ichs_sg_group_owner1) {
        return 'yes';
    }
    return 'no';
}

Hi,

Have you tried without scripting? And using the condition builder above the script field?

If by script, then:

answer = skipApproval();

function skipApproval() {

    var requested_for = current.variables.requested_for_v1;
    var sg_owner = current.variables.v_ichs_sg_group_owner1;
    var user = new GlideRecord("sys_user");
    user.get(requested_for);
    if (user.getValue('manager') == sg_owner) {
        return 'yes';
    }
    return 'no';
}

This is assuming you meant to use sg_owner instead of what you had in that if statement?


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

This is still not working. The condition for 'yes' is getting skipped even if the User manager is same as the Group owner. 

What other changes can be made? Please let me know.

 

Thanks in advance!