Catalog Task variable information in email

shane_davis
Tera Expert


I am trying to put the variable data into the "Email assigned to group (sc_task)" email notification so that the task assignment group will see what has been ordered, but am having no luck.   We have it on the Approval Request notification using the Notification Email Script below.   Does anyone have your catalog task emails including variable information?

We are on Fuji.   All help is appreciated!

template.print("<b>Summary of Requested items:\n</b>");

var item = new GlideRecord("sc_req_item");

item.addQuery("request", current.sysapproval);

item.query();

while(item.next()) { template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");

/*template.print("\n");*/

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.space(4); template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");

}

}

}

1 ACCEPTED SOLUTION

No problem. It will be like this then...



template.print("<b>Summary of Requested items:\n</b>");  


var item = new GlideRecord("sc_req_item");  


if (item.get(current.request_item.sys_id)) {


        template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");  


        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.space(4); template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");  


                  }  


        }


}  



Thanks,


Berny


View solution in original post

9 REPLIES 9

bernyalvarado
Mega Sage

Hi Shane, you can try with the following change in line 3



instead of having... :


item.addQuery("request", current.sysapproval);  




try... :  


item.addQuery("request", current.request);  



Thanks,


Berny


Berny,



        That worked perfect!   Thank you very much for your help.   I will mark your solution as the correct answer.



Shane


Berny,



        I responded too quick regarding exactly what I need. The code below is great for listing ALL RITM information from a request.   However, in this case, I only want the catalog task email to show the parent RITM the task is associated with.   I appreciate your help.   Thank you.



item.addQuery("request", current.request);  


No problem. It will be like this then...



template.print("<b>Summary of Requested items:\n</b>");  


var item = new GlideRecord("sc_req_item");  


if (item.get(current.request_item.sys_id)) {


        template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");  


        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.space(4); template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");  


                  }  


        }


}  



Thanks,


Berny