body is empty in email notification.

Juhi Jha
Tera Contributor

Hi Team,

I am trying to trigger a notification  email body is set as empty.

Below is my email script.

var record = new GlideRecord('sc_req_item');
record.get('76af537a87850110e93363150cbb353d'); //replace with your RITM sys_id
var vars = record.variables.getElements(true);
for (var i=0;i<vars.length;i++) {
var now_V = vars[i];
if (now_V.isMultiRow()) {
var rows = now_V.getRows();
for (var j=0; j<now_V.getRowCount(); j++) {
var row = rows[j];
var cells = row.getCells();
for (var k=0; k<cells.length; k++) {
var cell = cells[k];
if(cell.getCellDisplayValue() != ""){
gs.info(cell.getLabel() + ":" + cell.getCellDisplayValue());
}
}
}
}
else
{
var question = vars[i].getQuestion();
if(question.getDisplayValue() != ""){
gs.info(question.getLabel() + ":" + question.getDisplayValue());
}

}
}

 

In the background script it's working but getting blank body 

5 REPLIES 5

Sushma R1
Tera Expert
Could you elaborate, I do not understand this

this script prints variables of the RITM , in the background script i tested it is working but when i mentioned this email script in my notification i am getting blank body 

Are you using it as is in email script and embedding that email script in notification using $ ? Use template.print that will make sure to write it back on your notification body Hit helpful if it was

Kevin Paul
Mega Guru

Hi,

I think you have not printed anything that you want to appear in the mail template.

Whatever you want to be printed in the mail template, you should enclose that within the template.print() function.

Ex: Iam printing the start date and end date of a change

        template.print("<br/>Planned Start Date: " + start_date + " <br/>Planned End Date: " + end_date);

 

Hope this helps:)

Please mark correct/helpful if it has answered your query.