- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 02:41 AM
Hi everyone,
How can we combine multiple email scripts as one email script for fetching data on email body for different tables.
Scripts:
var gr = new GlideRecord("cmdb_ci_business_app");
gr.addQuery('assigned_to.name', event.parm2);
gr.query();
while (gr.next()) {
template.print(gr.number);
template.print("<br/>");
}
var gr = new GlideRecord("cmdb_ci_service_discovered");
gr.addQuery('assigned_to.name', event.parm2);
gr.query();
while (gr.next()) {
template.print(gr.number);
template.print("<br/>");
}
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 05:46 AM
we need to two email scripts in this case
Reason :
Events and notifications work in such a way that event is on the same table and the notification is on the same table .
So the your notification is on business app table and the event used there is business app so what ever you write in as event.parm1 and event.parm2 it will get only business app records even if you are glide recording another table and using event.parm2 of its corresponding event it wont catch the value it catches business app assigned to name only as the notification is on Business app table
so please have two email scripts in this case
please mark my answer correct if it helps you and close the thread
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 03:12 AM
Hi,
but the data shown by both email scripts is different.
what is the email script after merging? share the script
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-10-2022 03:24 AM
Hi,
after merging for both email scripts.
Script:
var gr = new GlideRecord("cmdb_ci_business_app");
gr.addQuery('assigned_to.name', event.parm2);
gr.query();
while (gr.next()) {
template.print(gr.number);
template.print("<br/>");
}
var gr1 = new GlideRecord("cmdb_ci_service_discovered");
gr1.addQuery('assigned_to.name', event.parm2);
gr1.query();
while (gr1.next()) {
template.print(gr1.number);
template.print("<br/>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 03:09 AM
If you have the 2 glide queries, shown in you post, in 1 script they cannot both be instantiated as gr, so you need to change one.
var gr = new GlideRecord("cmdb_ci_business_app");
gr.addQuery('assigned_to.name', event.parm2);
gr.query();
while (gr.next()) {
template.print(gr.number);
template.print("<br/>");
}
var anotherName = new GlideRecord("cmdb_ci_service_discovered");
anotherName.addQuery('assigned_to.name', event.parm2);
anotherName.query();
while (anotherName.next()) {
template.print(anotherName.number);
template.print("<br/>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 04:22 AM
Hi,
After merging I am not getting exact output.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 12:18 AM
Hi, ‘I am not getting exact output’ has no context as a response.
How does your question reconcile to the answer flagged as correct?