scripting help

Gary Larsen
Mega Sage

I am working on a BR to create a portal announcement when a p1 incident notification is created. I found a script in the community to create announcement for a knowledge BR and modified it I have it somewhat working but it creates a new announcement every time they update the P1.

the requirements would be to only have 1 Banner on the portal and for it to close 1 hour after the P1 is resolve email goes out. 

 

here is what I have working

 

(function executeRule(current, previous /*null when async*/) {
var announcementGR = new GlideRecord('announcement');
announcementGR.initialize();
announcementGR.name = 'Autocreated from ' + current.number;
announcementGR.title = current.u_banner_body;
var fromDateTime = new GlideDateTime(); // adjust date according to your needs
announcementGR.from = fromDateTime;
announcementGR.summary = current.text;
announcementGR.type = '52fa79f8e763320075c2a117c2f6a991'; // sys ID of 'Banner' type
announcementGR.display_style = '339ea11ae7d4030075c2a117c2f6a9cf'; //Urgent Style
announcementGR.insert();
})(current, previous);
 
was thinking when Notification type resolution is selected to fill the announcement to field with date and time 1 hour past submission time 
so my ask for help would be 
1. update current banner instead of creating new 
2. The resolution  notification to set to to field on announcement 
 
 
attaching screen grab of my P1 form  p1.PNG

 

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Sounds like you would be better of with a Flow since you are limited on scripting knowledge (and Flow is nowadays the first goto). Did you try that? Less or in your case most likely even zero code involved.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

2 REPLIES 2

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Sounds like you would be better of with a Flow since you are limited on scripting knowledge (and Flow is nowadays the first goto). Did you try that? Less or in your case most likely even zero code involved.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

all of our catalog item still use WF so not much experience with flow designer yet either but will try it out 

 

but so close to having that script working 

thanks