- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 11:23 AM
Good Day everyone,
I created this email script to read the information from my MRV to be added to the email notification.
However, in my MRV i have three reference fields that when i submit the form will only display their sys_id.
How do i get to display their actual values on the email script.
here is the code i am using:
var record = new GlideRecord('sc_req_item');
var sysCurrentRecordSysId = current.sys_id;
record.addQuery('sys_id', sysCurrentRecordSysId);
record.query();
while (record.next()) {
var obj = JSON.parse(record.variables.bill_to_office_mrv);//mvr name
for (var k = 0; k < obj.length; k++) {
' + obj[k].office_office + ' - ' + obj[k].department_office.getDisplayValue() + ' //Office & Department field you see in the pic above
' + obj[k].gl_code_office + ' // gl code
}
}
i tried using the .getDisplayedValue() on the department and it comes back with undefined.
any help is appricated here
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 01:09 PM
Oke no worries, I thought lets spend 5 minutes before bedtime 😅
I just modified the example slightly, works immediately on Catalog Item. You just need to replace the MRVS name and place the logic of your HTML table since I just used an example of building the description field.
var current = new GlideRecord('sc_req_item');
current.get('da8fa1bd479f29100692249bd36d43f5');
///
var description = [];
var mrvs = current.variables.mobile_devices_set;
var l = mrvs.getRowCount();
for(var i = 0; i < l; i++) {
var row = mrvs.getRow(i);
var cells = row.getCells();
var m = cells.length;
for(var j = 0; j < m; j++) {
description.push(cells[j].getLabel() + ': ' + cells[j].getCellDisplayValue());
}
if(i < l) {
description.push('');
}
}
gs.info(description);
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 11:47 AM
I believe that is because of how you get your MRV into a var. In your code you use
var obj = JSON.parse(record.variables.bill_to_office_mrv);//mvr name
But in @Mark Roethof example he just does
var mrvs = current.variables.mrvs_test;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:02 PM
in @Mark Roethof example it seem that he is using a record producer i am using a catalog item on the sc_req_item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:36 PM
But in the example he does one were you need a summary for a catalog task. Its in the last 1/3 of the post. Its similar to what you are doing.
But if you still cannot get it to work you basically need to lookup each sys_id in the appropriate table and get its display value. Which means doing a GlideRecord query for each sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:03 PM
in the example it seem that he is using a record producer i am using a catalog item on the sc_req_item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:51 PM
You do realize that a Record Producer is actually a Catalog Item 🙂
Anyway, it's not a copy/paste what I shared, you do have to put some effort in yourself. I just shared an example of that it can work fine without having to do additional GlideRecord queries for each sys_id.
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field