Send approval email to user stored in variable on catalog / request item

jfinn
Kilo Expert

I am currently testing a file share request system for our service catalog.   As part of this, the user will select the file share that they require access to from a drop down list.   All of the file shares are stored in a module in the CMDB and have approvers listed for each file share.

Once you select the share from the drop down list, a catalog client script does a lookup and populates a field called 'Approver' with the users name.   (this is a reference field which looks up the value from the sys_user table)

What I need to do is automate an email directly from the workflow on the service catalog which will email the approver to seek approval for access to the file share.

Has anybody done anything similar lately and if so, how can you do this.   If possible, I would rather put the value into the "To" field on the email rather than the cc or bcc field.

I have had a look on here but have not been able to do this.   Anybody got any ideas if this is possible?

14 REPLIES 14

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If the user is in a variable, you'll have to use an approval script in your Approval - User workflow activity to set the user.



answer = [];  


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


Hi Brad,



Sorry for being so late in coming back but I have now tried this and unfortunately, it is not working for me.  



If I hard code the email address such as below, it works perfect and sends the email for me.   However, this was for testing only as I need to be able to automate the sending of these emails from the system based on the value in my approver variable.



answer = 'john.doe@yourcompany.com';



I have also tried the following with no joy:



answer = current.variables.approver.sys_id;



and



answer = current.variables.approver;


answer = current.variables.approver.email;



where "approver" is my variable which is a reference field against the User[sys_user] table.



Am I missing something obvious here?


I should also add that I am entering this in the "To (script)" field on a notification activity on my workflow.



Below is a screenshot of my testing which are all currently commented out.



Script.JPG


jfinn
Kilo Expert

Anyone else got any ideas on what I am doing wrong here or even if this is possible?