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

Approval goes only to user selected from select box

Fotina Galieb
Tera Contributor

Hello, 

 

I am sicking of help, I got a request to create an approval step but only from one user from the group so the others dont see this approval. And requester needs to choose exact user who will approve. So I created select box 'approval_option' with questions, every choice is separate approver. So when requestor is choosing option 1, approval should go to user Adam. When option B, approval should go to Ben, when option 3 approval goes to Jack. I created in Workflow editor a step Approval-User and advanced approver with script :

 

var mainApprover = current.approval_option;

// mapping between approvers and user IDs

var approvers = {

'option_1': 'f5d1d2fd23456746e4b7714f0d4af57', // User ID for Adam 

'option_2': 'faa1d2fd9949010046e4b7714f0d4a0d, // User ID for Ben

'option_3': '3456783b495f569786429d5f9de973d2', // User ID for Jack

 

if (approvers[mainApprover]) {

var approvers = approvers[mainApprover];

return approvers;

}

 

What I am doing wrong? The approval always stick with error: Failed description. 

Did you already have a request that only one iuser of group can approve and it should be the one who requestor has chosen from the list?

Should i remove select box and create reference? But should i create custome table with these 3 people?

Please could you help?

 

Thank you!!!

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

This would be easier with a reference variable to choose the approver, then the script would just be:

 answer = current.variables.var_name

 and you wouldn’t need to hard-code (change later) the user sys_ids. If you want to stick with your approach, log ‘approvers’ to see if it contains a sys_id, then set it = answer as this must be set in Approval activities.