when new emergency change create send notification all vip users

AJAYKUMAR G
Tera Contributor

when new emergency change create send notification all vip users in business rule using with event.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @AJAYKUMAR G ,

You can do one small change to send email to VIP Users 

IN BR 

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

    // Add your code here
    var arrEmail = [];
    var gr = new GlideRecord('sys_user');
    gr.addQuery('vip', true);
    gr.query();
    while (gr.next()) {
        arrEmail.push(gr.sys_id.toString());
    }
    gs.log("arrEmail = " + arrEmail);
    gs.log("current.assigned_to.email = " + current.assigned_to.email);
    gs.eventQueue('emergency.change', current, arrEmail);

})(current, previous);

Add this code 

And in Notification pls do below thing

SarthakKashya2_0-1714145336809.png

You have to check true to this parm 1 and parm 2 variable 

 

Result 

 

SarthakKashya2_1-1714145392239.png

I have this 3 user is VIP and if we check the Email logs 

SarthakKashya2_2-1714145428200.png

 

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak

 

 

 

View solution in original post

9 REPLIES 9

Shree123
Tera Contributor

1. Create an event.

2. Trigger the event using gs.eventQueue('event name'), current, param1, param2) from your BR. Select insert as true.

Here in your param you can pass the VIP users.

3. Create a notification, Send when : Event is fired
Event name : Event created in step 1.
In Who will receive tab select event parm 1 contains recipient / event parm 2 contains recipient, wherever you're passing users.

script in business rule.

Example :

Business rule : After
Insert : true

Table : Change request
Condition : Type is emergency

var vip_users = [];
    var userGr = new GlideRecord('sys_user');
    userGr.addEncodedQuery('active=true^vip=true');
    userGr.query();
    while(userGr.next()){
        vip_users.push(userGr.getUniqueValue());
    }
    gs.eventQueue(('your_event_name'), current, vip_users);
 
However, you must check for any existing notifications and make sure that you want to notify ALL VIP users or certain set.

it is not working.