Script for user approval in catalog workflow

johnsonjohn
Tera Contributor

Hello - I am have a "user approval" activity in my catalog item's workflow and I want to use conditions to state who the approval should come from.  I can script the conditions, but I don't know how to script the approval parts.  It should look something like this:

If condition 1,

approval comes from person A

Else

approval comes from person B

The "approval comes from" part is what I don't know how to script.  I don't know if I've explained this properly, so please let me know if additional information is needed.  Thank you.

1 ACCEPTED SOLUTION

Hello John,

 

Use below code:

answer = [];
var mgr;

 

//Set manager to requested for if it's not empty, else set manager to requested by
if(!current.variables.u_requested_for) {

// check for the u_requested_for variable

//use either u_requested_for or requested_for
mgr = current.u_requested_for.manager;
}
else {
mgr = current.u_requested_by.manager;
}

 

answer.push(mgr);

 

 

 

View solution in original post

12 REPLIES 12

When I remove the second ! and make it if(!current.variables.requested_for) it always goes to the second condition (even when I have the "requested for" field populated).  When I add the second ! and make it if(!!current.variables.requested_for), it works correctly.

 

I don't know why that is, and even another developer on my team told me to use ! instead of !! -- but it doesn't work that way.

is the requested_for a variable or a field on the request item?

It is a reference field (it pulls from the User table), and the same with the requested_by -- also a reference field.