Need to create email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 06:17 AM
Hi All ,
I am trying to create an email notification using an Email script and also script include
I am trying to include the fields short description , description etc one above the other like the below :
I am using the below email script which I am using for the hyperlinks and having the above mentioned format for the entered dataa
Script :
(function runMailScript(current, template, email, email_action, event) {
try{
var task = current.sysapproval;
var class_name = task.sys_class_name.toString();
var content = new NonBatchNotificationContentnormalchange('sysapproval_approver').content;
var emailSub="";
//----------------------------------------------- Build Subject ----------------------------------------------
emailSub="change approval for "+task.number;
email.setSubject(emailSub);
//----------------------------------------------- Begin Build Body --------------------------------------------
var format = new EVG_EmailFormatter('IT_Outlook');
var body = "";
body += format.getSection('begin', {});
//----------------------------------------------- Add URL ----------------------------------------------------
body += format.getSection('url_section',{
'URL': gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + GlideStringUtil.urlEncode(gs.generateURL(current.getTableName(), current.sys_id)),
'CLICK_TEXT': "Click here to view Request"
});
body += format.getSection('url_section',{
'URL': gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + GlideStringUtil.urlEncode(gs.generateURL(class_name, task.sys_id)),
'CLICK_TEXT': "Click here to view " + task.number
});
//----------------------------------------------- Content Section --------------------------------------------
//format content fields into the email
body += format.getSection('begin_content_section', {});
for(var c in content.fields){
body += format.getSection('add_two_field_content_row',{
'FIELD': content.fields[c].field,
'CONTENT': content.fields[c].value
});
}
body += format.getSection('end_content_section_row', {});
body += format.getSection('add_description_row',{
'DESCRIPTION': task.description.toString().replace(/\n/g, "<br />")
});
body += format.getSection('end_content_section', {});
//----------------------------------------------- Approve or Reject ----------------------------------------------------
var apprv = "mailto:" + gs.getProperty('glide.email.user') + "?subject=Re:" + task.number + " - approve&body=" + email.watermark;
var rej = "mailto:" + gs.getProperty('glide.email.user') + "?subject=Re:" + task.number + " - reject&body=" + email.watermark;
body += "<tr style=\"padding-top:10px;padding-bottom:10px;\"><td width=\"100%\" style='width:100.0%;padding:0in 5.4pt 0in 5.4pt;padding-bottom:15px;'> <p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;text-align:center'> <span style='font-size:12.0pt; color:black'></span> <span style='font-family:\"Helvetica\",sans-serif;font-size:12.0pt'> <a href=\"mailto:" + gs.getProperty('glide.email.user') + "?subject=Re:" + task.number + " - approve&body=" + email.watermark + "\">Approve</a> | <a href=\"mailto:" + gs.getProperty('glide.email.user') + "?subject=Re:" + task.number + " - reject&body=" + email.watermark + "\">Reject</a> </span> </p> </td></tr>";
//----------------------------------------------- Set the Body ---------------------------------------------
body += format.getSection('end', {});
email.setBody(body);
//----------------------------------------------- If Error Thrown ----------------------------------------------
}catch(error_msg){
gs.log('Body Error - ' + error_msg, email_action.name);
}
})(current, template, email, email_action, event);
and in the below Script include I am setting up the above mentioned fields