Reference fields in my email script are printing the sysid's instead of the display value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 08:38 AM
Can anyone spot what i am doing wrong with this portion of the my emails script? I have a reference field, i want to print the display value of the field, but its displaying the sysid
Script:
// Check if the value is from the reference field
if (itemVars.sc_item_option.item_option_new.type == '8') {
var grRefTable = new GlideRecord(itemVars.sc_item_option.item_option_new.reference);
grRefTable.addQuery('sys_id', mvalue);
grRefTable.query();
if (grRefTable.next()) {
mvalue = grRefTable.getDisplayValue();
}
//updated on 8/27/24
template.print("<td>" + mvalue + "</td>");
template.print("</tr>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 08:43 AM
Hi @lando321,
Try using
// Check if the value is from the reference field
if (itemVars.sc_item_option.item_option_new.type == '8') {
var grRefTable = new GlideRecord(itemVars.sc_item_option.item_option_new.reference);
grRefTable.addQuery('sys_id', mvalue);
grRefTable.query();
if (grRefTable.next()) {
mvalue = grRefTable.getDisplayValue("name");
}
//updated on 8/27/24
template.print("<td>" + mvalue + "</td>");
template.print("</tr>");
}
Regards,
Ehab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 08:50 AM
Apologies, i left some vital information out. This script is being used across multiple catalog items. i updated the line in the script, but it still returned the sys id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 08:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 08:51 AM
@Amit Pandey i tried that, but still getting the sysid, should that "name" actually be the name of the variable?