Email script- get RITM variables

Sironi
Kilo Sage

Hi,

some one help me how to show below details in email notification

find_real_file.png

 

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/>");
}
}
}

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Sironi 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

13 REPLIES 13

Ankur Bawiskar
Tera Patron
Tera Patron

@Sironi 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Sironi 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Sironi 

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

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

i m very Sorry for delay reply on this. my apologizes 

 

kindly help me about , how the variables comes here.?

listVariableName

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader