- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 12:25 AM
Hi I am creating a email template where the Subject line should be as below but I am not getting the Item name.
Table Sysapproval_approver
Service Request REQxxxxx for "Item name" has been Approved
Email Script for Subject:
_________________________________________________________________________________
email.setSubject("Service Request " + $(sysapproval) + " " +"for" + " " + req + "has been approved");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next())
{
// template.print(gr.cat_item.getDisplayValue() + " ");
var req = gr.cat_item.getDisplayValue();
}
</mail script>
____________________________________________________________________________________
can anyone help where I am wrong in subject why isn't it retrieving the Item Name?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 03:50 AM
Not sure what exactly you are looking for but try the below and use the subject you want ...
<mail script>
var requestNumber = '';
var catalogName = '';
var ritmNumber = '';
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
if(gr.next())
{
catalogName = gr.cat_item.name.toString();
requestNumber = gr.request.number.toString();
ritmNumber = gr.number.toString();
}
email.setSubject("Service Request " + requestNumber + " " +"for" + " " + catalogName + " has been approved");
//email.setSubject("Service Request " + ritmNumber + " " +"for" + " " + catalogName + " has been approved");
</mail script>
Note : The template must be running on sysapproval_approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 01:03 AM
Also declare req globally .. i.e . before GlideRecord Statement .. Like below
<mail_script>
var req ="" ;
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next())
{
// template.print(gr.cat_item.getDisplayValue() + " ");
req = gr.cat_item.getDisplayValue();
}
email.setSubject("Service Request " + $(sysapproval) + " " +"for" + " " + req + "has been approved");
</mail script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:01 AM
i tried this as email script" but subject is not coming. The issue is with only req without req its coming well and good.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
email.setSubject("Service Request " + $(sysapproval) + " " +"for" + " " + req + "has been approved");
var req = "";
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next())
{
var req = gr.cat_item.getDisplayValue();
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:14 AM
One request could have multiple of RITMS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:18 AM
But if it has one in that case it should display the Item name in req. is is not coming due to that reason?
In body of email template it displays fine, but for subject line its not comming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 02:21 AM
in while loop replace instruction
var req = gr.cat_item.getDisplayValue();
with
var req = gr.getDisplayValue();
also try to add a log inside while loop to check weather control enters inside it or not