- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2020 06:39 AM
Hello!
I was looking for some help with figuring out the lines needed in an email script to display the value of a reference variable in a multi row variable set. The two variables in question are 'select_district' and 'building'.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, template.print('<table border="0px solid black">'); template.print( "<tr>" );
})(current, template, email, email_action, event); |
When .getDisplayValue is added, it returns as undefined. When left as 'building' is, it returns the sys ID instead of the reference value. Any help with this would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2020 08:56 AM
Hi,
you cannot use getDisplayValue() here
you need to query those 2 tables with that sys_id and get the display value and then print
var gr = new GlideRecord('district table'); // give proper table name here
gr.addQuery('sys_id', row.select_district);
gr.query();
if(gr.next()){
template.print( "<td><left>" +gr.name + "</left></td>" ); // give here the field on district table which stores name
}
var gr = new GlideRecord('building_table'); // give proper table name here
gr.addQuery('sys_id', row.building);
gr.query();
if(gr.next()){
template.print( "<td><left>" +gr.name+ "</left></td>" ); // give here the field on building table which stores name
}
Mark as Correct Answer & Helpful if this solves your issue or Helpful if this is useful to you.
Regards
Anukr
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2021 02:58 PM
Worked like a charm!!