- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 04:57 AM
Hi Everyone,
I need to stop triggering notification multiple time from scheduled job.
script:
var gr = new GlideRecord("cmdb_ci_business_app");
gr.addEncodedQuery('assigned_to.active=false^assigned_to.sys_updated_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');
gr.query();
while (gr.next()) {
gs.eventQueue('fa.business.app.accountable.owner', gr, gr.assigned_to.manager.email, gr.assigned_to);
}
var gr1 = new GlideRecord("cmdb_ci_service_discovered");
gr1.addEncodedQuery('assigned_to.active=false^assigned_to.sys_updated_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');
gr1.query();
while (gr1.next()) {
gs.eventQueue('fa.business.app.accountable.owner', gr1, gr1.assigned_to.manager.email, gr1.assigned_to);
}
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 06:15 AM
Example:
1) I push assigned to and assigned to manager into array and sent as parameter1.In the notification check the check box recipient contains parm1 under whom to send
2)Then i push all the business app names into an array and sen as parameter 2
var bussinessArr=[];
var bussRecipients=[];
var gr = new GlideRecord("cmdb_ci_business_app");
gr.addEncodedQuery('assigned_to.active=false^assigned_to.sys_updated_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');
gr.query();
while (gr.next()) {
bussinessArr.push(gr.name.toString());
bussRecipients.push(gr.assigned_to.manager.toString());
bussRecipients.push(gr.assigned_to.toString());
}
gs.eventQueue('fa.business.app.accountable.owner', gr, bussRecipients , bussinessArr);
Now create a email script like below
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var busApps = event.parm2;
template.print('please find the Business apps which are assinged to users whoc are incative under you');
for(var i=0;i<busApps.length;i++)
{
template.print("Business App :"+i+" "+ busApps[i]);
}
})(current, template, email, email_action, event);
Then call this email script in your notification as ${mail_script:your_mail_Script_name}
this way you can send a single notification to inactive users managers with multiple records
Hope this helps
please mark my answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 06:15 AM
Example:
1) I push assigned to and assigned to manager into array and sent as parameter1.In the notification check the check box recipient contains parm1 under whom to send
2)Then i push all the business app names into an array and sen as parameter 2
var bussinessArr=[];
var bussRecipients=[];
var gr = new GlideRecord("cmdb_ci_business_app");
gr.addEncodedQuery('assigned_to.active=false^assigned_to.sys_updated_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');
gr.query();
while (gr.next()) {
bussinessArr.push(gr.name.toString());
bussRecipients.push(gr.assigned_to.manager.toString());
bussRecipients.push(gr.assigned_to.toString());
}
gs.eventQueue('fa.business.app.accountable.owner', gr, bussRecipients , bussinessArr);
Now create a email script like below
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var busApps = event.parm2;
template.print('please find the Business apps which are assinged to users whoc are incative under you');
for(var i=0;i<busApps.length;i++)
{
template.print("Business App :"+i+" "+ busApps[i]);
}
})(current, template, email, email_action, event);
Then call this email script in your notification as ${mail_script:your_mail_Script_name}
this way you can send a single notification to inactive users managers with multiple records
Hope this helps
please mark my answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 06:41 AM
Thanks for the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 09:14 AM
Hi Mohith,
it's only working for one user, not for multiple users. can you please let me know any suggestions.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 09:18 AM
HELLO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-04-2022 09:36 AM
I need to send notification on every monday 7am, on (business application and application services) tables where users(assigned_to) are in inactive then notification needs to send to their manager with inactive users records on email body.
Right now I am facing issue, it's only working one user inactive and not for multiple inactive users.
Good Morning,
Your employee (A Arjun Rao (aarao)) was the Accountable Owner for the following Business Application(s) and/or Application Service(s) and is now inactive, causing the workflow(s) to stopBusiness Application(s)
APM0002151
APM0002289
APM0001673
APM0001950
APM0001234
APM0001513
Application Service(s)
AS0000003540
AS0000002132
AS0000003512
AS0000003450
AS0000002766
AS0000003312
Please complete the CMDB Application Request (CSDM) to modify the Accountable Owner for the Business Application(s) and/or Application Service(s) for each listed above. A video guide with instructions for submitting this form is available here.
Thanks