How to remove announcements from announcement widget and banner when incident is resolved.

Rose17
Tera Contributor

Hi All,

When an incident is promoted to major incident, the major incidents should be shown in announcement widget in portal.

I have created a BR to create announcement which is perfectly working fine.

Below is the BR to create incident announcement-

Type- Async, insert, update. Condition- when major incident state is accepted.

find_real_file.png

Now I want to remove the announcement from widget and banner in portal when incident is resolved/closed.

This is possible when the announcement record is made inactive and field- 'to' (type- glide date time) has some value in it.

To remove the incident from announcement widget- Announcement should become inactive

To remove the incident from banner as well- Field- 'to' in announcement table should have a current/before date/time value in it.

I  have written another BR to remove announcement as below, but it doesn't seem to work.

Async, update, condition- state changes to resolved or state changes to closed.

find_real_file.png

Could someone help me to achieve this asap?

@Ankur Bawiskar Your help is highly appreciable.

Thanks in advance.

 

1 ACCEPTED SOLUTION

Hi,

As I told the update from 2nd BR might be causing the 1st BR to run and insert

try to adjust 1st BR condition to check if record already exists or not

if not then only create new record into announcement table

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Hi,

Did you try checking the query returned the correct record?

if the query is satisfied then it should update and not create.

Possibly then update is triggering the 1st BR and creating new record.

try to adjust that BR condition

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

2nd BR is making correct record as active=false.

But i dont know why new record is created after 2nd BR runs?

What needs to be changed?

Also the query is returning the correct record. 

Check both the sys_ids in below screenshots-

 

find_real_file.png

 

find_real_file.png

Hi,

Did you add logs in the 2nd BR?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes.

The sys_ids in announcement record and logs is the same.

this is the script-

(function executeRule(current, previous /*null when async*/ ) {
var grAnRecord = new GlideRecord('announcement');
gs.addInfoMessage('hello');
if(grAnRecord.get('name',current.sys_id))
{
gs.log('test ruhi' +grAnRecord.name);
grAnRecord.active = false;
grAnRecord.update();
}

})(current, previous);

 

Logs-

find_real_file.png

 

Announcement records-

find_real_file.png

Hi,

As I told the update from 2nd BR might be causing the 1st BR to run and insert

try to adjust 1st BR condition to check if record already exists or not

if not then only create new record into announcement table

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader