automated email to inform leavers about their computers to return before leaving the company

mani55
Tera Contributor

we wish to add an automated email to inform leavers about their computers to return before leaving the company. This to avoid the surprise and the confusion of many users who discover that they need to take back some computers they do not use anymore when they are coming to the onsite support at their last day of work.

An email must be sent to the leaver with the manager and also the user who has created the pc surrender request (the Open by) in Cc. The email must include the references of all computers associated to the leaver to return before the estimated date of the final departure (date filled in the request).
 
i written below email script :
 

 

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

var user = event.parm1;

var arr = [];

var gr = new GlideRecord('cmdb_ci'); // table name changed
gr.addQuery('assigned_to', user);
gr.query();
while(gr.next()){

var str = gr.asset_tag + ' - ' + gr.name + ' - ' + gr.model_id.getDisplayValue();

arr.push(str.toString());

}

template.print('<ul>');
for(var i=0;i<arr.length;i++){
template.print('<li>' + arr[i] + '</li>')
}
template.print('<ul>');

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

 

 

 

Notification body:

 

mani55_0-1721738528328.png

 

 

present script is working fine but for example user have two assets then we need to display second asset details into asset 2 line but present all assets details displaying in asset 1 line so please help me how to get asset 2 line with asset 2 detalis

2 REPLIES 2

Brian Lancaster
Tera Sage

Get ride of the right and left parenthesis in your mail script name.

may i know how to do that