Workflow Activity - Approval User - Advanced - BROKEN

adrian08
Tera Contributor

Hi folks, 

 

I noticed a very interesting behavior. Whenever we script out the list of approvers, we tick Advanced, correct. Here SNOW will suggest doing it like:

 

 

answer = [];

answer.push('id1');

answer.push('id2');

 

 

However, this is broken if we I am getting the approver from anything from the current.variable field of the RITM. For this to work, it has to be set like this:

 

 

answer = (function(current) {

var arr = [];
//set arr.push();
return arr
})(current);

 

 

 

So if the later code the best and and safest way to declare and script approvers? 

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

I use the suggested format exclusively, with success.  How are you experiencing it 'broken' when using a variable value?  Note that the variable should be a reference, or otherwise contain a sys_id as its value, and as a best practice / coding standard, ALWAYS force sys_ids to a string when pushing them to an array in any Javascript:

answer.push(current.variables.requested_for.toString());