Email Notification Subject

snowuser111
Kilo Guru

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

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

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


View solution in original post

23 REPLIES 23

Yes , its should work .


So if it is as below:


Notification table is : sysapproval_approver


&


Email Template: sysapproval_approver


In Notification template you are using only sysapproval_approver 's sys_id to retrieve the data from sc_req_item table so you just need to have Email Template table: sysapproval_approver



The notification table may effect the fields like to whom you are sending the notification... Like if you are sending the notification to requester and notification table is request then in 'who will receive' field should have Requester (caller id) in it but if notification is on sysapproval_approver table then you have to replace it with Approval for.requester (sysapproval.caller_id) .


Use it according to your need.


Thanks for the clarification