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

Please find the attachment, the same is working in my PDI.

Community Alums
Not applicable

Hi @AJAYKUMAR G ,

I tried your problem in my PDI and it's working fine for me 

Please use below reference 

1. Create Before BR

SarthakKashya2_0-1714138528028.png

Add below script 

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

	// Add your code here
	gs.log("current.assigned_to.email = " + current.assigned_to.email);
	gs.eventQueue('emergency.change', current, current.assigned_to.email);

})(current, previous);

2. Create Event from Event Registry

SarthakKashya2_1-1714138578055.png

3. Create Notification 

SarthakKashya2_2-1714138624835.png

SarthakKashya2_3-1714138641783.png

Add VIP users here 

SarthakKashya2_4-1714138665845.png

You can add your content here 

 

Result : 

When I change the type to Emergency Email triggered

SarthakKashya2_5-1714138706689.png

 

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

 

Thanks and Regards 

Sarthak

 

 

 

 

 

 

Sarthak Kashya2

I need send to send notification to all vip users from user table.

 

@AJAYKUMAR G 
Did you try what I have attached? 

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