- 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-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
11-08-2020 10:18 PM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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
11-11-2020 04:59 AM
Hope you are doing good.
Let me know if I have answered your question..
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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
11-17-2020 09:15 AM
Hi Ankur,
i m very Sorry for delay reply on this. my apologizes
kindly help me about , how the variables comes here.?
listVariableName
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2020 08:28 PM
Hi,
you are having list collector variable right
So you use that variable name there and also the table being referred in the GlideRecord
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
