- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 02:39 PM
Hi,
some one help me how to show below details in email notification
how to show Owner name in Notification body
template.print("<b>Summary of Requested items:\n</b>");
var item = new GlideRecord("sc_req_item");
if (item.get(current.document_id)) {
template.print("<b>"+item.number + ": " + item.cat_item.getDisplayValue() + "</b><br/>");
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '') {
template.print("<b>"+vs.get(i).getLabel() +"</b>"+ " : " + vs.get(i).getDisplayValue() + "<br/>");
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2020 01:46 AM
As mentioned by Pradeep you need to query the table and get the value
Sample script below which is updated
Ensure you give valid table names, list variable name , field names, etc
template.print("<b>Summary of Requested items:\n</b>");
var item = new GlideRecord("sc_req_item");
if (item.get(current.document_id)) {
template.print("<b>"+item.number + ": " + item.cat_item.getDisplayValue() + "</b><br/>");
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '' && vs.get(i).getName() != 'listVariableName') {
template.print("<b>"+vs.get(i).getLabel() +"</b>"+ " : " + vs.get(i).getDisplayValue() + "<br/>");
}
if(vs.get(i).getName() == 'listVariableName'){
var gr = new GlideRecord('table name'); // give table name being referred by list variable
gr.addQuery('sys_id', 'IN', item.variables.<listVariable>);
gr.query();
while(gr.next()){
template.print('Owner is' + gr.<ownerField> + '<br/>');
}
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 02:43 PM
Hi Sironi - It looks like you want to get field column value of the referenced target table. If yes, then you have to GlideRecord to the target table based on the matching variable value.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 02:47 PM
Hi Pradeep,
can you give some background steps ,how to query that particular variable ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 01:15 PM
can i expect any updates / suggestions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2020 10:23 PM
Sorry for the delay in my response. Give it a try with script shared and let us know if you have any additional question.