Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to send notification for all change task group after completing change request in servicenow

vamshi2
Tera Contributor

Hi Team

Please suggest configuration to send notification for all change task assignment group members after completing parent change request

8 REPLIES 8

Hi @Ankur Bawiskar 

Thank you so much for your reply

i am able to store all users sysid in one flow variable with your help

but i am facing issue with 4 th point to store unique values could you please explain in brief

@vamshi2 

Glad to know that my approach worked.

the 2nd flow variable will store unique users from array.

Something like this you can use "Set Flow Variables" flow logic once the For Each ends

var finalUsers = fd_data.flow_var.flowVariableName.toString().split(',');

var arrayUtil = global.ArrayUtil();

finalUsers = arrayUtil.unique(finalUsers);

return finalUsers.toString();

AnkurBawiskar_0-1762846441095.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Sarthak Kashyap
Mega Sage

Hi @vamshi2 ,

 

I tried your whole problem in my PDI and it works for me please check below solution

I Create a event - "send.notification.when.request.closed"

SarthakKashyap_0-1762759265446.png

After that I created a Notification that triggered when event is called 

SarthakKashyap_1-1762759302042.png

Create a before BR and add below script 

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

    // Add your code here
    gs.log("BR Called");
    var groups = [];
    var users = [];
    var gr = new GlideRecord("change_task");
    gr.addQuery("change_request", current.getUniqueValue());
    gr.query();
    while (gr.next()) {
        groups.push(gr.assignment_group.toString());
    }
    var groupGr = new GlideRecord("sys_user_grmember");
    groupGr.addEncodedQuery("nameIN" + groups);
    groupGr.query();
    while (groupGr.next()) {
        gs.log("Inside while for users");
        users.push(groupGr.user.toString());
    }


    gs.log("groups - " + groups);
    gs.log("User - " + users);
    gs.eventQueue("send.notification.when.request.closed", current, users.join(","), "");
})(current, previous);

SarthakKashyap_6-1762759727458.png

 

SarthakKashyap_3-1762759378582.png

 

Result:

SarthakKashyap_4-1762759435943.png

Once I close this change_request it will send notification to all users of change task assignment group

SarthakKashyap_5-1762759488999.png

 

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

Thanks and Regards,

Sarthak

Hi @Sarthak Kashyap 

Thanks for the reply

i am implementing using flow design as shown 

vamshi2_0-1762773860013.png


vamshi2_1-1762773905022.png



it is working but it is triggering twice if user is part of two groups so please suggest