- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 03:01 AM
Hi All,
My requirement is to create one notification for 2 different catalogs and notification should contain variable of particular catalog item.For example i have 2 catalogs:
Catalog 1(Server Request ) have fields "Server 1,Server 2 and Server 3"
Catalog 2(database Request ) have field "database 1,database 2 and database 3"
notifications should be triggered once RITM get created and this notification should contains "Server 1 and Server 2" if Catalog 1 gets submitted and "database 1,database 2" should be populated it Catalog 2 gets submitted.
how we can achieve this with one email script?
If any idea please share with me.
Thanks in Advance.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 05:09 AM
Hi,
You can write the email script and call it in your notification.
Name = "multiple_cat_item_example"
(function runMailScript(current, template, email, email_action, event) {
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id', current.sys_id);
gr.query();
if (gr.next())
{
if (gr.cat_item == 'sys_id_of_catalog1') {
template.print(current.variables.server_1);
template.print(current.variables.server_2);
template.print(current.variables.server_3);
email.setSubject("For catalog item 1");
}
else if (gr.cat_item == 'sys_id_of_catalog2') {
template.print(current.variables.database1);
template.print(current.variables.database2);
template.print(current.variables.database3);
email.setSubject("For catalog item 2");
}
}
})(current, template, email, email_action, event);
})(current, template, email, email_action, event);
Now call the email script in the notification What it will Contain >> Message HTML
${mail_script:multiple_cat_item_example}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 05:09 AM
Hi,
You can write the email script and call it in your notification.
Name = "multiple_cat_item_example"
(function runMailScript(current, template, email, email_action, event) {
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id', current.sys_id);
gr.query();
if (gr.next())
{
if (gr.cat_item == 'sys_id_of_catalog1') {
template.print(current.variables.server_1);
template.print(current.variables.server_2);
template.print(current.variables.server_3);
email.setSubject("For catalog item 1");
}
else if (gr.cat_item == 'sys_id_of_catalog2') {
template.print(current.variables.database1);
template.print(current.variables.database2);
template.print(current.variables.database3);
email.setSubject("For catalog item 2");
}
}
})(current, template, email, email_action, event);
})(current, template, email, email_action, event);
Now call the email script in the notification What it will Contain >> Message HTML
${mail_script:multiple_cat_item_example}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 06:23 AM
Thank you Ankur for your response.
Few changes in the code and it worked for me.
I am also trying to send email to different users based on catalog
email.setReplyTo(current.variables.owner);
but its not triggering to the owner.
Can you please help me here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 06:37 AM
Hi,
*is the Owner filed referring to 'sys_user' table?
If this is the case then modify the line according to below code:
email.setReplyTo(current.variables.owner.email);
If i was able to help you and you achieved you implement this then please mark the content as "Correct Answer", That can other community users to find their similar answer easily.
Thanks,
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 06:47 AM
Hi Ankur,
yes i tried this also but no luck
email.setReplyTo(current.variables.owner.email);