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 09:13 PM
Hi @kam4 ,
please check this community post
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Arun Manoj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 12:48 AM
Dear Arun,
Thank you for your sharing and I have tried it the same script, but it does not able to show the information in the email notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 09:21 PM
this should help you
Multi-row variable set in Notifications via Notifications Email Script
update your script as this
(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-15-2025 11:49 PM
Dear Ankur,
Thank you for your solution but it was able to show the table or information shown the email notification.
here the email scripts I have change accordingly.
"