Catalog Item Variables in Workflow Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 08:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 08:05 AM
depending on what table your sending the notificaton from, the variable live on the sc_req_item table so if your sending from the sc_task (catalog task) table it would be current.request_item.variables.variablename
if it's from sc_req_item (the item itself) it would just be current.variables.variablename
here's a pretty good examples of using them and actually printing the variable label etc.
Scripting for Email Notifications - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 08:06 AM
That is exactly what I use and it seems to work just fine for us: ${current.variables.nameOfVariable}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 09:48 AM
Thank you very much for your quick response.
One more question- I want to send this notification to variable-project manager (referenced to user table)
in To (script) of Notification section (see my original post with screenshot), I wrote the following script:
// Set the variable 'answer' to a comma-separated list of user or group sys_ids that you want the email sent to.
answer =current.variable_pool.project_manager;
Is this right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 10:06 AM
I'm not sure if your way will work or not because I've never tried it that way. I was not able to get a variable reference into the TO: field unless I fed that variable into a field on the form first. Then you can just use that form field in the notifiction. But I have this mail script in the body of the email that added the person referenced in the variable (sys_user table) to the BCC field. I didn't do the CC field because our version of SN (Berlin) has a bug in it that doesn't allow the CC script:
<mail_script>
var supMail = current.variables.nameOfReferenceVariable.email;
var supName = current.variables.nameOfReferenceVariable.getDisplayValue();
email.addAddress("bcc", supMail, supName);
</mail_script>
This places that email in the BCC field. One caveat is that you still HAVE to have someone or a user field in the TO or it won't send. For us, that was fine, we wanted to also send the same notification to the opened_by. There is a tiny bit more on that here:
Scripting for Email Notifications - ServiceNow Wiki
Hope this helps a bit!