- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2019 11:39 PM
Hi all,
Actually i have an issue with fetching the multi row variable set values in email notification which are reference variables while fetching it's populating sys_id in my code i have added getDispalyValue() then it's showing undefined so could you please any one guid me how to get that value. here am attaching my code and screen shots for your reference .
template.print('<table border="1px solid black">');
template.print( "<tr bgcolor='#ddd'align='center'>" );
template.print("<td style='text-align:center' colspan='10'><strong>Asset Allocation</strong></td>");
template.print( "</tr>" );
template.print( "<tr>" );
template.print( "<td><left><b>SAP_ASSETID </b></left></td>" );
template.print( "<td><left><b>ASSET_DESCRIPTION </b></left></td>" );
template.print( "<td><left><b>BOND_NO</b></left></td>" );
template.print( "<td><left><b>BOND_DATE</b></left></td>" );
template.print( "<td><left><b>COSTCENTER</b></left></td>" );
template.print( "<td><left><b>SERIAL_NO</b></left></td>" );
template.print( "<td><left><b>ASSETID</b></left></td>" );
// template.print( "<td><left><b>CITY</b></left></td>" );
// template.print( "<td><left><b>BUILDING</b></left></td>" );
// template.print( "<td><left><b>FLOOR</b></left></td>" );
// template.print( "<td><left><b>CUBICLE</b></left></td>" );
template.print( "</tr>" );
var mvrs = current.variables.asset_information;
var ritm = current.getUniqueValue();
var rowCount = mvrs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mvrs.getRow(i);
template.print( "<tr>" );
template.print( "<td><left>" +row.sap_asset_number + "</left></td>" );
template.print( "<td><left>" +row.asset_description + "</left></td>" );
template.print( "<td><left>" +row.bond_number + "</left></td>" );
template.print( "<td><left>" +row.bond_date + "</left></td>" );
template.print( "<td><left>" +row.sap_cost_center_code + "</left></td>" );
template.print( "<td><left>" +row.serial_number + "</left></td>" );
template.print( "<td><left>" +row.asset_id + "</left></td>" );
template.print( "</tr>" );
}
template.print('</table>');
NOTE:-i have tried with row.sap_cost_center_code.getDispalyValue() then it's showing undefined for both fields
Advance thanks,
Regards,
sai bhargav p.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 03:17 AM
template.print('<table border="1px solid black">');
template.print( "<tr bgcolor='#ddd'align='center'>" );
template.print("<td style='text-align:center' colspan='10'><strong>Asset Allocation</strong></td>");
template.print( "</tr>" );
template.print( "<tr>" );
template.print( "<td><left><b>SAP_ASSETID </b></left></td>" );
template.print( "<td><left><b>ASSET_DESCRIPTION </b></left></td>" );
template.print( "<td><left><b>BOND_NO</b></left></td>" );
template.print( "<td><left><b>BOND_DATE</b></left></td>" );
template.print( "<td><left><b>COSTCENTER</b></left></td>" );
template.print( "<td><left><b>SERIAL_NO</b></left></td>" );
template.print( "<td><left><b>ASSETID</b></left></td>" );
// template.print( "<td><left><b>CITY</b></left></td>" );
// template.print( "<td><left><b>BUILDING</b></left></td>" );
// template.print( "<td><left><b>FLOOR</b></left></td>" );
// template.print( "<td><left><b>CUBICLE</b></left></td>" );
template.print( "</tr>" );
var mvrs = current.variables.asset_information;
var ritm = current.getUniqueValue();
var rowCount = mvrs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mvrs.getRow(i);
var gr = new GlideRecord('<refence variable table name'>);
gr.get('sys_id',row.sap_cost_center_code);
var res = gr.name; //kindly check which column holds the name
var gr2 = new GlideRecord('<second reference variable table name'>);
gr2.get('sys_id',row.asset_id);
var res2 = gr2.name; //kindly check which column holds the name
template.print( "<tr>" );
template.print( "<td><left>" +row.sap_asset_number + "</left></td>" );
template.print( "<td><left>" +row.asset_description + "</left></td>" );
template.print( "<td><left>" +row.bond_number + "</left></td>" );
template.print( "<td><left>" +row.bond_date + "</left></td>" );
template.print( "<td><left>" +res+ "</left></td>" );
template.print( "<td><left>" +row.serial_number + "</left></td>" );
template.print( "<td><left>" +res2 + "</left></td>" );
template.print( "</tr>" );
}
template.print('</table>');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2019 11:43 PM
Hi there,
This is because the variables, also for multi-row variable sets, are stored as Strings. So you're actually getting exactly what you're asking 🙂
You would have to use some scripting thru mail scripts to achieve this, unfortunately. Though, you could grab that opportunity to make your notification a bit more flexible.
Take a look at the Multi Row Question Answer table [sc_multi_row_question_answer], and you will see your variables - and the string values - there.
If my answer helped you in any way, please then mark it as helpful.
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
03-22-2019 12:12 AM
Hi thank you for your response Mark , can you please do me a small favor if possible , actually i am beginner in scripting so could you please modify my script accordingly and let me know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2019 11:46 PM
For example:
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
03-22-2019 12:18 AM
anyhow you need to do the glide-record on the reference table to get the display value so i would suggest here either you add the glide-record in your email script it self while fetching it.
if you will write an email script on "sc_multi_row_question_answer" table to get the multi row reference variable value it will give you the sysid because on that table column "Value" it stored the sysid.
give a try to add another glidrecord on reference table to fetch the sysid display value.