Workflow generating duplicate approver

Joshua Comeau
Kilo Sage

Noticed:
Need to correct the duplicate approval that occurs when the
User Information - Approver: User Information is the same as the Module
"Who is your approver?"

 

Any ideas on the script to query so that whenever the user that is selected here:

JoshuaComeau_0-1681389061373.png

 

Will not generate another approver when the name matches here:

JoshuaComeau_1-1681389078526.png

 

4 REPLIES 4

Prince Arora
Tera Sage
Tera Sage

@Joshua Comeau 

 

Their might a workflow in the backend, can you share your workflow logic, so that I can help you out.

Because approvals have been sent via workflow.

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

Workflow:

 

the IF statement has the following currently:

JoshuaComeau_1-1681391444906.png

 

JoshuaComeau_0-1681391407554.png

 

Prince Arora
Tera Sage
Tera Sage

@Joshua Comeau 

 

Could you please tell me which activity is responsible for user information approval and which activity is responsible for Who is the approver? Because I am unable to determine the correct path OR let me suggest you something just add it accordingly, what ever the ---> goes towards the second approval please add a if activity before that:

 

 

You need to check whether

if(current.variables.userInfoApproval != current.variables.Who_IS_THE_Approver ){

answer = "yes";

}else

answer = "No";

 

It will go to that direction only when both are not similar, I hope this helps!

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

johansec
Tera Guru

So couple things both around scratch pad variables

 

  1. Store appover ids in an array after each approval and prevent it before the next by using an if
    1. At the start of the workflow you create a script activity
      1. The script will create an empty array assigned to a scratchpad variable that will be used later to keep track of every user who has approved . 
    2. After the first approval ( and each other one ) you can have a script activity that will push the previous approver into the scratchpad array. 
    3. Then before each approval or just the one your worried about a dupe you can have an if right before the approval 
      1. inside the if you would check to see if the next approvers id is in the scratchpad array. 
      2. if indexOf(current.variables.ApprovalField) ==-1 then continue to the approval if not then skip that one.
  2. Option two is store all approver ids in a scratchpad array and iterate through them and create approvals. Before adding each one to the array make sure they are not already there. 
    1. Script at start of the workflow 
      1. Create scratchpad approval array 
      2. Create scratchpad approval index counter variable ( to know where we are at in the array ) 
      3. Add each approver in order to the array from your variables 
    2. If statement to check if our index counter is at the length of the approver array
      1. if not then we get the approver at that index and create an approval 
        1. then script to increment the index 
        2. then go back to the if statement to see if we have another approver 
      2. Else if the index is at max we know we made through each approver we needed and good to go