Need to dynamically change the recipient of a notification within Worfklow Studio

neil_b
Tera Guru

Hi, 

 

I have created a flow that is triggered when a user is deactivated and to do a look up for any requests they submitted and for each request, send a notification to the Assigned To user so that the request isn't ignored and still gets completed.

Inactive User Notification.png

The challenge I face is that I have an IF logic step implemented to where if the Assigned To on the request is empty, I would like the notification to be sent to an Admin Group. If I don't do this, then the notification won't get sent out because there won't be a recipient.


I don't see a way to accomplish this in the Workflow Studio. Can someone please review my attached flow and advise me how I can achieve adding the Admins Group as the recipient of the notification if the Assigned To is empty?

1 ACCEPTED SOLUTION

Hi @neil_b,

 

I was able to reproduce and work on your scenario on my PDI. Please follow below instructions:

 

Create a new Event Registry in sysevent_register as follow:

MediC_0-1742324037593.png

 

On your Notification, "When to send" tab, adjust is as follow by setting the event you created in previous step:

MediC_1-1742324109256.png

In the "Who will receive"  tab, check "Event parm1 contains recipient"

MediC_4-1742324354783.png

 

 

In your Flow, you won't need "if else", you can use "Fire event" action:

MediC_2-1742324181359.png

MediC_3-1742324202055.png

in the Parameter 1, please provide following script:

return fd_data._2__for_each.item.assigned_to || "b85d44954a3623120004689b2d5dd60a";
_2__for_each: should be replaced with your "For each" statement. If it is in position 3 for example it should be _3__for_each.
Replace the sys_id with your Admins group sys_id
 
I have tested it on my PDI and it should do the work. I hope this help!

 

 

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

View solution in original post

16 REPLIES 16

Ah I forgot about flow properties, let me try that route and see if I am able to achieve this. Thanks so much @Jean Ferreira ! I will report back with my findings!

Shivalika
Mega Sage
Mega Sage

Hello @neil_b 

 

Mail script would work here. 

 

Write the below mail script - 

// Get the assigned user from the record

var assignedToUser = current.assigned_to;

 

// Initialize recipient variable

var recipientEmail = 'default_recipient@example.com'; // Default email if no user is assigned

 

// Check if Assigned To field has a value

if (assignedToUser && assignedToUser.email) {

    recipientEmail = assignedToUser.email;

}

 

// Set the "To" field dynamically

email.setTo(recipientEmail);

 

This will dynamically change the recipient of the email.

 

If you add any recipient in groups or users field on the notification who will receive it will always send to those users or groups which doesn't aligns with your requirement. But this mail script will help you dynamically set it. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

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

 

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