- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 09:57 PM
What are the equivalent variables in email scripts?
Fields in sc_request table can be easily accessed from workflow or notification, but how to access them in email scripts?
For example:
In notification: ${sysapproval.description}, ${sysapproval.short_description}
In workflow script: current.description, current.short_description
In email script: ???, ???
They all correspond to the description or short_description column in the sc_request table. What is the equivalent of them in the email scripts?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2019 11:13 PM
Dear Mr. Harshvardhan,
Thank you for your help. The following code is working. I can read the sc_request table columns.
You are great.
Liuduan
var req = new GlideRecord("sc_request");
req.addQuery('sys_id', current.sysapproval.sys_id);
req.query();
gs.info("test 1: ");
while(req.next()) {
gs.info("test 2: " + req.short_description);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 10:07 PM
You have to do glide record in emails script to fetch that values.
(function runMailScript(current, template, email, email_action, event) {
var req = new GlideRecord("sc_request");
req.addQuery("sys_id", current.request);
req.query();
while(req.next()) {
template.print(req.short_description + ' ' +req.description);
}
})(current, template, email, email_action, event);
Note: I am assuming here your notification is running on sc_req_item table .
For further details refer the below doc link.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 10:53 PM
I run the email script as part of the email template. In the email template I can access the description field of the sc_request table like this: ${sysapproval.description}. What level is it?
I run the following code in my mail script, and the while(req.next()){} is not working.
var req = new GlideRecord("sc_request");
req.addQuery("sys_id", current.request);
req.query();
gs.info("test 7.9.3: "); // This info is showoing
while(req.next()) {
gs.info("test 7.9.4: " + req.short_description); // This info is not showing
}
Please help me and give me some suggestions. Thank you.
Duan Liu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 10:58 PM
req.addQuery("sys_id", current.request);
Could the above line a problem? That is the part that always confuses me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 11:02 PM
try now
var req = new GlideRecord("sc_request");
req.addQuery("sys_id", current.sys_id);
req.query();
gs.info("test 7.9.3: "); // This info is showoing
while(req.next()) {
gs.info("test 7.9.4: " + req.short_description); // This info is not showing
}