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

Jaspal Singh
Mega Patron
Mega Patron

Tyoo

template.print(evidence.evidence_details.getDisplayValue);

should be

template.print(evidence.evidence_details.getDisplayValue());

Or simply keep

template.print(evidence.evidence_details);

as its non-reference type field.

template.print(evidence.evidence_details.getDisplayValue());

- No Change (shows nothing).

 

template.print(evidence.evidence_details);

-Shows undefined.

Can you 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('sys_id',current.sys_id);
        evidenceis.query();
        if(evidenceis.next())
{

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

 

What table notification is on? If it is on same table as GlideRecord in script as above you can simply use

${evidence_details} in the notificaiton body instead of using mail script