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

Berny,



        Yes, now that is perfect.   Thank you!



Shane


Teri Bobst
Mega Guru

Hi Berny, I need to be able to print variables in the email notification where Visible on Summaries is set to True. I have multiple workflow variables that print with this code and it doesn't make sense for the approver or requester to see those and they will be blank until the required tasks are completed.


How could I modify this code so that only variables set to Visible on Summaries would print?



Thanks,


Teri


If you are still looking for this info. I was able to omit any unwanted information by doing the following:



if(vs.get(i).getLabel() != '' && vs.get(i).getLabel() != 'Selected Products' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'null' && vs.get(i).getDisplayValue() != 'false')


jituksingh
Kilo Guru

Hi,



Can you please let me know how and where I can use this script to pull variables in task notification?



Regards,


Jitendra Singh


Notification email scripts. PFA



Capture.PNG



Please mark my response as correct and helpful if it helped solved your question.
-Thanks