How to send the notification with all the populated data in the requested item

Poorna Chandu
Tera Contributor

Hello Everyone,

I have a requirement where I need to send the notification via mail script with all the data in the requested item. Can anyone help me in achieving this.

9 REPLIES 9

umaaggarwal
Giga Guru
Giga Guru

Hi,

If you are creating notification on RITM table, you can use current to access RITM fields and current.variables.<variable_name> to use variables on it, however if you are creating notification on any other table which is linked to RITM , you can use below sample script ( modify as per your needs) in email script and then you can call it in notifications

 

template.print("Summary of Requested items:<br />");  
var now_GR = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
  template.print(gr.number + ":  " + gr.quantity + " X " + gr.cat_item.getDisplayValue() 
                   + " at " + gr.cat_item.price.getDisplayValue() + " each <br />");
}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can have notification on sc_req_item table and use email script to fetch all the variables under that catalog item and show in email

what did you start with and where are you stuck?

Regards
Ankur

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

Hello Ankur,

Thanks for your reply. I have written mail script and called that on notification. It worked with the variables I used as current.variables.variable name. But actual my problem is if am using current. variables I need to write for every variable where I have data in the requested item.

I want a script so that notification can be send only with the variables which has data in the requested item instead of writing each and every variable.

Is there any way to do this

Hello Poorna,

Please check my answer, may be it satisfies your requirement.

Please mark it as right if it helps you.

BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.