How to send the notification with all the populated data in the requested item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 07:08 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 07:16 AM
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 />");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 07:17 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 07:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 07:41 AM
Hello Poorna,
Please check my answer, may be it satisfies your requirement.
Please mark it as right if it helps you.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.