
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2022 10:51 PM
I would like to have a portal announcement created when an outage is created. I don't really care if it is automatic or requires some other prompt, like if a checkbox is selected on the outage form then create an announcement for example.
I figure a business rule or an event might be the way to go, but I really have no idea how to start either as when I choose a table, I have no idea how to link to the other table - announcement or outage.
I'd also want the end date being added to the outage to auto de activate the announcement.
I've already found this previous question, but it is not at all helpful:
Creating Announcements from Outages
If you have an idea can you also please include some details - I won't know how to go further without at least a bit of a start.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 12:23 AM
Sorry My bad,
Create 2 BR,
For Update :-
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("announcement");
gr.addEncodedQuery("active=true^nameLIKE"+current.number);
gr.query();
if (gr.next()) {
gr.to=current.end;
gr.update();
}
})(current, previous);
For Insert :-
BR only after Insert
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("announcement");
gr.initialize();
gr.name = 'Outage Number' + current.number + ' created.';
gr.title = 'Outage For' + current.getDisplayValue('cmdb_ci') + ' is created.';
gr.summary = current.short_description;
gr.active = 'true';
gr.from = new GlideDateTime();
gr.insert();
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2022 11:02 PM - edited ‎11-15-2022 11:04 PM
Hi @Bidduam ,
You can writedown after insert Business rule on cmdb_ci_outage table as below
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("announcement");
gr.initialize();
gr.name = 'Outage Number' + current.number + ' created.';
gr.title = 'Outage For' + current.getDisplayValue('cmdb_ci') + ' is created.';
gr.summary = current.short_description;
gr.active = 'true';
gr.from = new GlideDateTime();
gr.update();
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 12:04 AM
@Gunjan Kiratkar that is awesome thank you.
Do you have any ideas on how to close the announcement once the outage is ended? Just by adding the end date in the outage record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 12:08 AM - edited ‎11-16-2022 12:17 AM
Hi @Bidduam ,
yes then make your BR after Update/Insert and make below changes
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("announcement");
gr.initialize();
gr.name = 'Outage Number' + current.number + ' created.';
gr.title = 'Outage For' + current.getDisplayValue('cmdb_ci') + ' is created.';
gr.summary = current.short_description;
gr.active = 'true';
gr.from = new GlideDateTime();
if(current.end!=''){
gr.to=current.end;
}
gr.insert();
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 12:23 AM
Sorry My bad,
Create 2 BR,
For Update :-
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("announcement");
gr.addEncodedQuery("active=true^nameLIKE"+current.number);
gr.query();
if (gr.next()) {
gr.to=current.end;
gr.update();
}
})(current, previous);
For Insert :-
BR only after Insert
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("announcement");
gr.initialize();
gr.name = 'Outage Number' + current.number + ' created.';
gr.title = 'Outage For' + current.getDisplayValue('cmdb_ci') + ' is created.';
gr.summary = current.short_description;
gr.active = 'true';
gr.from = new GlideDateTime();
gr.insert();
})(current, previous);