P1 automatic SP announcement

EduardoH
Tera Contributor

Hi, everybody

 

We are in a practice environment, I need to comply with the following story

Set Announcements for when P1 priority Incidents are created, should disappear only when the ticket is Resolved. The announcement should include:
*Ticket number
*Description
*Should link directly to the INC Form for the ticket.

 

But I'm struggling with:

-It creates a new announcement when insert and update. But when the p1 is updated for any reason, it creates another announcement. But need it, in case a regular case upgrade to P1.

-how to code that the announcement goes away once the incident is resolved.

-how to code the redirect to the ticket's INC form.

I had managed the following using a BS:

 

I got the following:

Business rule
Details
When to run, tab
After
Insert, Update
Filter condition
Priority | is | 1 - Critical
Actions, tab
none
Advance, tab

 

(function executeRule(current, previous /*null when async*/ ) {
    createAnnouncement();

    function createAnnouncement() {
        //Current group name
        var currentGroup = '';
        if (current.assignment_group) {
            var assigmentGroup = new GlideRecord('sys_user_group');
            if (assigmentGroup.get(current.assignment_group.sys_id)) {
                currentGroup = assigmentGroup.name;
            }
        }
        var gr = new GlideRecord('announcement');
        gr.initialize();
        gr.name = 'Priority 1 Incident open'; //New one in the announcement table  
        gr.title = 'On Going Priority 1 - ' + currentGroup + ' is working to resolve it ASAP -'; //Announcement title, showing on SP
        gr.summary = 'We are currently facing issues with ' + current.short_description + '. The Incident ' + current.number + ', has been create as Priority 1.'; //Announcement summary, showing on SP
        gr.setDisplayValue('display_style', 'Urgent'); //Set Display style by field value
        gr.click_target = 'urlNew';
        gr.details_url = '/sp?id=kb_article&sys_id=' + current.sys_id;
        gr.details_link_text = 'More Info';
        var success = gr.insert();
        if (success) {
            createPortalEntry(gr.sys_id);
        }
    }

    function createPortalEntry(announceID) {
        var gr1 = new GlideRecord('m2m_announcement_portal');
        gr1.initialize();
        gr1.announcement = announceID;
        gr1.sp_portal = '81b75d3147032100ba13a5554ee4902b'; //Service Portal Sys id
        gr1.insert();
    }
})(current, previous);
 
bs.png

I'll appreciate any light that you can trough into my practice. thank you

0 REPLIES 0