unable to insert mvrs data into email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 09:00 PM
Hi Al,
I have an issue where i have create an email notification and try to insert mvrs data into the email notification content but it was not able to show anything, I attach the screenshot for your reference.
email notification Table
Requested Item (SC_re_item)
Email script
name: PrintMRVSData
scripts:
"(function runMailScript(current, template, email, email_action, event) {
// Get the sys_id of the requested item
var ritmSysId = current.sys_id;
// Get the MRVS data (example: 'u_mrvs_variable_name')
var mrvsData = current.variables.u_vs_user_info_celonis; // Replace with your MRVS variable name
// Check if data exists
if (mrvsData && mrvsData.getRowCount() > 0) {
var tableHtml = '<table>';
tableHtml += '<tr><th>Column 1</th><th>Column 2</th></tr>'; // Replace with your column headers
for (var i = 0; i < mrvsData.getRowCount(); i++) {
var row = mrvsData.getRow(i);
tableHtml += '<tr>';
tableHtml += '<td>' + row.u_region + '</td>'; // Replace with your column values
tableHtml += '<td>' + row.u_region + '</td>';
tableHtml += '</tr>';
}
tableHtml += '</table>';
template.print(tableHtml);
} else {
template.print('No data found in Multi-row variable set.');
}
})(current, template, email, email_action, event);"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 11:59 PM
sorry didn't get.
is it not working or working fine?
share some screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 12:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 09:29 PM
does your catalog item have MRVS in it?
did you add logs and see?
you used the wrong script and not the one I shared
here is my script
(function runMailScript(current, template, email, email_action, event) {
// Replace with your actual MRVS variable name
var mrvsVarName = 'u_vs_user_info_celonis';
var mrvsData = current.variables[mrvsVarName];
if (mrvsData) {
// Parse the JSON string
var rows = JSON.parse(mrvsData + '');
if (rows.length > 0) {
var tableHtml = '<table border="1"><tr><th>Region</th></tr>';
for (var i = 0; i < rows.length; i++) {
tableHtml += '<tr><td>' + rows[i].u_region + '</td></tr>';
}
tableHtml += '</table>';
template.print(tableHtml);
} else {
template.print('No data found in Multi-row variable set.');
}
} else {
template.print('No data found in Multi-row variable set.');
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 11:35 PM - edited 06-17-2025 11:59 PM
Dear Ankur,
I have 2 question.
1. Do we have to distinguish between email notification from table is requested item (sc_req_item) or Approval (sysapproval_approver)? because the email notification is from the table Approval (sysapproval_approver).
2. Do I need to put the current.variable name from the mvrs variables? if yes the variables i create is current.variables.u_region
I attach the MVRS variable for your reference.
I hope to get an answer from you.
Thank You
Regards,
TMKam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 12:34 AM
yes you need to distinguish between those 2 tables
if notification is on RITM then you can access directly
if notification is on approval then you need to query RITM and then use that GlideRecord object.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader