HRSD - Approval Flow

SandeshD
Tera Contributor

Hi Team , 

 

We want to sent approval to Manager of the Subject Person.

Challenge is , Subject Person's Manager1 --- > Approves ----> Manager1's Manager2 ---> Manager2's ---> Manager3 , and so on until the Manager field in User table is empty.

 

Actually, the idea is to send approval as per hierarchy , Manager - Associate Director - Director - VP , etc.

1 ACCEPTED SOLUTION

Madhava_Kumar
Mega Guru

Madhava_Kumar_0-1743766950119.png

1) The first Run Script code is below

 workflow.scratchpad.manager = current.variables.RequestedFor.manager;
(RequestedFor is a variable) 
2) Approval User Activity give the approver as 
 workflow.scratchpad.manager
3) If condition to check whether the  workflow.scratchpad.manager has a Manager or Not?
If yes then save the Manager value into the workflow.scratchpad.manager.
If no then it will close complete.
 
answer = ifScript();
function ifScript() {
    var gr = new GlideRecord("sys_user");
    gr.addEncodedQuery('sys_id=' + workflow.scratchpad.manager);
    gr.query();
    if (gr.next()) {
        if (gr.manager != '') {
            workflow.scratchpad.manager = gr.manager;
            return 'yes';
        }
    }
    return 'no';
}
4) Re-direct again to the Approval user. So that it will continue triggering the manager approval until the IF Condition is NO.
 
Mark Helpful, if its works for you.
Thanks

View solution in original post

4 REPLIES 4

J Siva
Tera Sage

Hi @SandeshD 
May i know, how you are managing the HR case life cycle? Workflow or flow designer?

SandeshD
Tera Contributor

Workflow

Robert H
Mega Sage

Hello @SandeshD ,

 

I'm not sure I fully understand your requirement.

 

Do you really need the approval from every manager in the hierarchy "until the Manager field in User table is empty"? Meaning the last approver would be the CEO?

I don't think that would be feasible because it's unknown how many approval steps need to be configured. If a low level employee is the subject person then there would be more approval steps than if a VP were the subject person.

 

Or do you just need the approval from the "next 3 managers" in the hierarchy?

 

Regards,

Robert

Madhava_Kumar
Mega Guru

Madhava_Kumar_0-1743766950119.png

1) The first Run Script code is below

 workflow.scratchpad.manager = current.variables.RequestedFor.manager;
(RequestedFor is a variable) 
2) Approval User Activity give the approver as 
 workflow.scratchpad.manager
3) If condition to check whether the  workflow.scratchpad.manager has a Manager or Not?
If yes then save the Manager value into the workflow.scratchpad.manager.
If no then it will close complete.
 
answer = ifScript();
function ifScript() {
    var gr = new GlideRecord("sys_user");
    gr.addEncodedQuery('sys_id=' + workflow.scratchpad.manager);
    gr.query();
    if (gr.next()) {
        if (gr.manager != '') {
            workflow.scratchpad.manager = gr.manager;
            return 'yes';
        }
    }
    return 'no';
}
4) Re-direct again to the Approval user. So that it will continue triggering the manager approval until the IF Condition is NO.
 
Mark Helpful, if its works for you.
Thanks