Approval from a Variable

alexcharleswort
Tera Expert

I am currently working on a workflow and messing around with some approvals. In my form, I have the user fill out a "who is your manager?" field from a reference. I want to, then, have the approval task pull from the field they filled out in the form and email that specific manager for approval. Thoughts/ideas?

1 ACCEPTED SOLUTION

Hi Alex,



In the approval activity, check the advanced checkbox and put the following in the script field. You're pushing two user ids to an array for the approval activity to use.



answer = [];


answer.push(current.variables.manager.sys_id);


answer.push(current.variables.div_dir.sys_id);


View solution in original post

11 REPLIES 11

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Alex,



You can do this from the approval script in the approval activity. Something like:



answer.push(current.variables.variablename);


My scripting is not so great. I might need you to hold my hand through this one a little more. That script totally makes sense in theory but I can't get it to work no matter what variation I use.


So I am going to break it down with some visuals...variable.PNG


I am trying to get the user to input a manager and director so that the two people they input will need to go in an approve their order for equipment. So, I am thinking that the variables I use will be "manager" and "div_dir".


and to cover my bases I pulled the sys_id for the manager...sys_id.PNG


so variables have been established and noted for workflow use...workflow.PNG


I have my workflow ready to go and just need to fine tune the "approval user".


What, exactly, would I put as my script in there for this to work (including all the grammatical punctuation and whatnot).


I would appreciate any and all help!!!!! Thank you!


Hi Alex,



In the approval activity, check the advanced checkbox and put the following in the script field. You're pushing two user ids to an array for the approval activity to use.



answer = [];


answer.push(current.variables.manager.sys_id);


answer.push(current.variables.div_dir.sys_id);


You are awesome! Worked splendidly! Thanks