how to create different email notifications for a catalog item

Nag9
Tera Expert

Hi All, I have below requirement for  creating different email notifications to a catalog item "ABC"

Req:1 

I want sent a email notification like below template to the requester

Email1: Email upon submittal. To: Requester, Trigger: Submittal of completed (all mandatory fields populated) property removal form

 

 

find_real_file.png

Req 2: I want sent mail to the infrastructure owner(Variable in catalog item)

Email2: Please approve or reject. To: Infrastructure Owner, Trigger: Submittal of completed (all mandatory fields populated) property removal form

 

find_real_file.png

 

Req:3

i want sent mail to the approvers in Ritm form

Email: Please approve or reject. To: Next approver in the workflow , Trigger: Approval by the previous approver

find_real_file.png

 

Req:4 

I want sent mail to All approvers

Email4: Approval. To: Requester. Trigger: All approver have approved the request.

find_real_file.png

 

Req:5 

I want sent a mail to requester if approval is rejected

Email5: Rejection To: Requester. Trigger: One approver has rejected the request

find_real_file.png

 

How to acheive above the requirements can any one please post some script for this

Thanks in advance.

 

 

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Go to Notifications and start configuring for each of those points.

Let me know if you have any questions.

Mark the comment as helpful if it helps.

View solution in original post

25 REPLIES 25

Tried asif, by using glide record, still its not getting data in body.here is the code

 

(function runMailScript(current, template, email, email_action, event) {

// Add your code here
var req = new GlideRecord("sc_req_item");
req.addQuery('number',current.number);
//gr.addQuery("request", current.sysapproval);
req.query();
while(gr.next()) {
{
template.print("Property removal identifier (RITM):" + current.variables.number.getDisplayValue() + '<br/> <br/>');
template.print("Requestor:" + current.variables.opened_by.getDisplayValue() + '<br/> <br/>');
template.print("Requested date:" + current.variables.opened_at.getDisplayValue() + '<br/> <br/>');

}
}
var gr = new GlideRecord("sc_cat_item");
gr.addEncodedQuery('name=Property Removal Form');
//gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
{
template.print("Device Recipient Name:" + current.variables.Recepient_name_reference.getDisplayValue() + '<br/> <br/>');
template.print("Can device be destroyed?:" + current.variables.device_destroyed.getDisplayValue() + '<br/> <br/>');
template.print("Site:" + current.variables.Site.getDisplayValue() + '<br/> <br/>');
template.print("Quantity:" + current.variables.u_quantity1.getDisplayValue() + '<br/> <br/>');
template.print("Device Type:" + current.variables.device_type.getDisplayValue() + '<br/> <br/>');

template.print("Equipment_location:" + current.variables.equipment_location1.getDisplayValue() + '<br/> <br/>');
template.print("Equipment_location:" + current.variables.equipment_location2.getDisplayValue() + '<br/> <br/>');


template.print("Description of Item:" + current.variables.Item_description1.getDisplayValue() + '<br/> <br/>');
template.print("Description of Item:" + current.variables.Item_description2.getDisplayValue() + '<br/> <br/>');
<br/>');

template.print("Device Name:" + current.variables.device_name1.getDisplayValue() + '<br/> <br/>');
template.print("Device Name:" + current.variables.device_name2.getDisplayValue() + '<br/> <br/>');

template.print("Serial Number:" + current.variables.serial_number1.getDisplayValue() + '<br/> <br/>');
template.print("Serial Number:" + current.variables.serial_number2.getDisplayValue() + '<br/> <br/>');

}
}
})(current, template, email, email_action, event);

Im trying to executing below script , but no lick its not getting any values in notification body.

 

(function runMailScript(current, template, email, email_action, event) {

// Add your code here
var req = new GlideRecord("sc_req_item");
req.addQuery('request',current.request);
req.query();
while(gr.next()) {
{
template.print("Property removal identifier (RITM):" + current.variables.number.getDisplayValue() + '<br/> <br/>');
template.print("Requestor:" + current.variables.opened_by.getDisplayValue() + '<br/> <br/>');
template.print("Requested date:" + current.variables.opened_at.getDisplayValue() + '<br/> <br/>');

}
}

// the above part is not executing


var gr = new GlideRecord("sc_cat_item");
gr.addEncodedQuery('name=Property Removal Form');
gr.query();
while(gr.next()) {
{
template.print("Device Recipient Name:" + current.variables.Recepient_name_reference.getDisplayValue() + '<br/> <br/>');
template.print("Can device be destroyed?:" + current.variables.device_destroyed.getDisplayValue() + '<br/> <br/>');
template.print("Site:" + current.variables.Site.getDisplayValue() + '<br/> <br/>');
template.print("Quantity:" + current.variables.u_quantity1.getDisplayValue() + '<br/> <br/>');
template.print("Device Type:" + current.variables.device_type.getDisplayValue() + '<br/> <br/>');

}

//this part is executing,but values are not displaying

})(current, template, email, email_action, event);

Im trying to executing below script , but no lick its not getting any values in notification body.

 

(function runMailScript(current, template, email, email_action, event) {

// Add your code here
var req = new GlideRecord("sc_req_item");
req.addQuery('request',current.request);
req.query();
while(gr.next()) {
{
template.print("Property removal identifier (RITM):" + current.variables.number.getDisplayValue() + '<br/> <br/>');
template.print("Requestor:" + current.variables.opened_by.getDisplayValue() + '<br/> <br/>');
template.print("Requested date:" + current.variables.opened_at.getDisplayValue() + '<br/> <br/>');

}
}

// the above part is not executing


var gr = new GlideRecord("sc_cat_item");
gr.addEncodedQuery('name=Property Removal Form');
gr.query();
while(gr.next()) {
{
template.print("Device Recipient Name:" + current.variables.Recepient_name_reference.getDisplayValue() + '<br/> <br/>');
template.print("Can device be destroyed?:" + current.variables.device_destroyed.getDisplayValue() + '<br/> <br/>');
template.print("Site:" + current.variables.Site.getDisplayValue() + '<br/> <br/>');
template.print("Quantity:" + current.variables.u_quantity1.getDisplayValue() + '<br/> <br/>');
template.print("Device Type:" + current.variables.device_type.getDisplayValue() + '<br/> <br/>');

}

//this part is executing,but values are not displaying

})(current, template, email, email_action, event);

 

Can please look in this once

Hi Nag,

Kindly pay attention to the details.

1. Regarding yoru 1st code, first print the value of this and check what it contains

gs.log("Request is "+current.request);

2. Regarding 2nd query, as metnioned earlier, if your notification is running on sysapproval_approver table, then current.variables will not work. Current.variables will work only if its running on the request item.

So instead of current, use gr.getValue() and try to dispaly those values in the template.

 

 

gs.log is not reflecting and get value function also is not working

 

template.print("Device Recipient Name:" + gr.getValue().Recepient_name_reference() + '<br/> <br/>');

 

is this correct syntax?