Email Notification Request Number and all its RITM

Fredo1
Giga Expert

I want to send an email with a summary with the Request Number and all the RITM's

I have the following script

template.print('<p>' + 'Click here to view request: ' + '${request.URI_REF}');

template.print("<br />");

template.print("Summary of Requested items:");

template.print("<br />");

var gr = new GlideRecord("sc_req_item");

//gr.addQuery("request", current.sys_id);

gr.addQuery("sys_id", current.sysapproval);

gr.query();

while(gr.next()) {

      }

      template.print(gr.number + ":   " + gr.cat_item.getDisplayValue());

}

But, I only get this

Click here to view request: REQ0010312

Summary of Requested items:

undefined: undefined

Can you let me know what I have wrong?

Many thanks in advance...

1 ACCEPTED SOLUTION

Please check now, above code contains brackets closed between while and template. Now copy paste the exact code and check the results and please let me know.



template.print('<p>' + 'Click here to view request: ' + '${request.URI_REF}');


template.print("<br />");


template.print("Summary of Requested items:");


template.print("<br />");


var gr = new GlideRecord("sc_req_item");


gr.addQuery('request',current.request);


gr.query();


while(gr.next()) {


//}   remove this line, because of this it prints one record only.


      template.print(gr.number + ":   " + gr.cat_item.name);


}


View solution in original post

19 REPLIES 19

BALAJI40
Mega Sage

try this one,



template.print('<p>' + 'Click here to view request: ' + '${request.URI_REF}');


template.print("<br />");


template.print("Summary of Requested items:");


template.print("<br />");


var gr = new GlideRecord("sc_req_item");


gr.addQuery("request.number",${request.URI_REF});


gr.query();


while(gr.next()) {


      }


      template.print(gr.number + ":   " + gr.cat_item.getDisplayValue());


}


Thanks Bajali but it didn't work



I made a comparison between my email notification and the "Request Opened on Behalf" that comes OOB.



Mine, I created from the sc_req_item table and the   "Request Opened on Behalf" is from sc_request table.



don't know if thta above has to do with me not getting results.


No problem it should work. Its not related to table which you selected, here your selected request item table so notification triggers on request table.


Try one more time with the same script, by giving codes to query condition.



template.print('<p>' + 'Click here to view request: ' + '${request.URI_REF}');


template.print("<br />");


template.print("Summary of Requested items:");


template.print("<br />");


var gr = new GlideRecord("sc_req_item");


gr.addQuery('sys_id',current.sys_id); replace this line with previous


gr.query();


while(gr.next()) {


      }


      template.print(gr.number + ":   " + gr.cat_item.getDisplayValue());


}


Sorry, don't understand...



Can you post the script? or the whole line that I need to add?



Thanks