Populate Assignment Group members first name in Email body of notifications

VullankiL
Tera Contributor

Hi,

I have a requirement like, whenever a task is created or re-opened, I need to send a notification to Assignment group members and the user in Assigned to field.
Now I have taken who will receive like this:

VullankiL_0-1739350755306.png

Now, In the Email body, I need to put "Hello ${userName} ", for that I want to populate the ${userName} with the individual recipient's first name for each notification triggered. How to do that?

If I put assigned_to.first_name, then it will only work for Assigned to, otherwise it is showing empty..
Please Help me with this.

Thank you,

4 REPLIES 4

Kieran Anson
Kilo Patron

Hi,

You would need to fire an event per-person you wish to receive the email, that way you are able to personalise the notification. 

Hi @Kieran Anson,

Can you please elaborate it more. Because I have to do the same thing in the notification.

Thanks and Regards,
Pratap Singh Sisodia

In a Business Rule you can use the following. The below is for a task record with a populated wish list. It loops over each user in the watch list and generates an event. Your notification will then look for this event to trigger an outbound email.

 

In your notification record ${event.parm1} would be the firstName value to use

(function(current, previous) {

    //If watch list is empty, do nothing
    if (current.watch_list.nil())
        return;

    //split the glide_list into a usable array
    var watchListArr = current.getValue('watch_list').split(',');

    //loop over the array, firing an event per user
    //watch_list can contain sys_id OR an email address
    watchListArr.forEach(function(user) {
        //Nicely attempt to find the user by their sys_id
        //if 'user' is an email address, we use
        //GlideQueries 'orElse' to return the email address
        //as the first name value
        var firstName = new global.GlideQuery('sys_user')
            .get(user, ['first_name'])
            .orElse({
                'first_name': user
            }).first_name;

        //fire our custom event
        gs.eventQueue(
            'my_event', /** event name */
			/** the record the notification is for **/ current,
            firstName /**Name value to use in the notification */ ,
            user /** the sys_id / email address */
			);
    });


})(current, previous)

 

Shivalika
Mega Sage

Hello @VullankiL 

 

If such is your requirement why aare you even using general notifications to achieve them. Just use Flow Designer.

 

1)Look Up records in "sys_uset_grmember".

2)For each record send an email - this way you will have customised email for all. No need to fire so many events. 

 

Have you tried this out ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY QQ