- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2018 05:36 AM
I am fairly new to ServiceNow development and scripting. I want to know how to reference variables from a User Approval step in a workflow. The workflow is triggered by a Training Request that is picked from the Service Catalog.
The goal is to present an email notification to the approver with all the variables the requestor filled out. I want to use the runMailScript function in a Notification Email Script to do this but using current.variable.<variable_name> returns "undefined".
I also want to know how to grab sys_id from the sc_req_item that was generated to be able to query its field values.
Any help is greatly appreciated.
Thanks,
Ritchie
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2018 05:41 AM
Hi Ritchie,
Not sure if you got a chance to go through below links.
Variables in Task notifications
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2018 05:41 AM
Hi Ritchie,
Not sure if you got a chance to go through below links.
Variables in Task notifications
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2018 06:43 AM
The reason "current.variable.<variable_name>" isn't working for you is because the "current" record for approval notifications is the approval record itself which has no variables. The linked training request is the record with the variables.
I would suggest looking at the out of the box "request.itil.approve.role" email template as an example. When a catalog request requires approval, an email goes out summarizing all the requested items and includes the variables as well. The message in that template has a script that captures the variables. You will see it "dot-walks" to the sysapproval reference field which is a link to the request, and in your case should be the training request (assuming it extends the task table).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2018 10:52 AM
Thanks, looking at that template really helped. Do you know what other methods can be used besides getLabel() and getDisplayValue(). I am trying to make the email dynamic which is why I created a mail script in the first place.