We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Mail Script is not showing correctly in Preview Notification.

Aaron Duncan
Mega Sage

I have a notification with the following line.

Evidence Collection Instructions: ${mail_script:evidence_evidence_collection_instructions}

 

Looking at the mail script, I have the following. Line 7 & 8 should point to the following field on the screenshot below. 

As you can see, the evident_details field is an html field. I need help to see why it is not carrying the data over to the notification.

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
    var evidence = new GlideRecord('sn_grc_advanced_evidence_collection_details');
	evidence.getValue(current.evidence_details);
	template.print(evidence.evidence_details.getDisplayValue);
	
})(current, template, email, email_action, event);

 

SCREENSHOT:find_real_file.png

 

EMAIL Preview: Missing data.

find_real_file.png

1 ACCEPTED SOLUTION

Thanks. Looking at screenshot I assume evidence_reqeust is common field between 2 tables with same values

Try below

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
    var evidenceis = new GlideRecord('sn_grc_advanced_evidence_collection_details');
	evidenceis.addQuery('evidence_request',current.sys_id);
//evidence_reqeust I assume is common field between 2 tables
        evidenceis.query();
        if(evidenceis.next())
{

	template.print(evidenceis.evidence_details);
}
	
})(current, template, email, email_action, event);

View solution in original post

7 REPLIES 7

It is on a different table. I'm brand new to GRC, so I'm not familiar with the table structure at all.

 

find_real_file.png

 

Also, I tried your latest script, and it returned nothing.

Thanks. Looking at screenshot I assume evidence_reqeust is common field between 2 tables with same values

Try below

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
    var evidenceis = new GlideRecord('sn_grc_advanced_evidence_collection_details');
	evidenceis.addQuery('evidence_request',current.sys_id);
//evidence_reqeust I assume is common field between 2 tables
        evidenceis.query();
        if(evidenceis.next())
{

	template.print(evidenceis.evidence_details);
}
	
})(current, template, email, email_action, event);

That script worked, thank you!