How to set up dynamic email recipients for various use cases within one email notification?

Linda6
Mega Guru

Hi Community,

 

I have a notification that should be sent out to a specific user OR group of users, depending on the use case that is applicable for the given incident.

The assigned_to field is not mandatory. So if it's not filled in before saving the form, an automatic assignment of the incident shall happen as follows:

 

1) first check if there are any team members of a special group of users (this is not the current assignment group, but another group created specially for this automated assignment cases, let's call it group 'X').  Check for any internal/external user from the group, who is NOT the team lead of this group 'X'    ->  this is <queryA>

 

if there is no teammember in group 'X', then:

 

2) check whether there is any team leader in group 'X'    -> this is <queryB>

 

if there is none, then:

 

3) determine the department via department.parent and continue with this group in point 4

 

4) if this assignment group is already a department itself, then assign to any active teammember (NOT a team leader) in that assignment group

-> this is <queryC>

 

5) if no teammember found, try to find the team leader of that group -> <queryD>

 

6) send the notification not to assignment group 'X', but to all users from the 'assignment_group' field -> <queryE>

 

Well now, what I have done so far:

- created an event

- created a basic business rule that will trigger the event

- created the notification that will run after the event is fired, where in Who will receive both Event parm 1 contains recipient and also Event parm 2 contains recipient are ticked (first shall save the sysID/s of the specific users, the second save the sysID of the incident to which this is applied)

- I do have the queries ready, not pasting them here

 

What I do not know, is how to put together the script for the above mentioned conditions, as I'm new to scripting.

I believe I can pull of putting together the if/else conditions with their queries, what I do not know, is how to push/save the sysID/s of the email recipient in an object or string and then use it as a parameter.

Can someone pretty please direct me?

 

I went through a lot of articles here, but did not really find anything really applicable to this issue, where there are more use cases for the same matter.

 

Thank you so much in advance

1 REPLY 1

tenzin choephel
Tera Expert

Hi Linda,

 

Are you trying to pass the recipients list on the BR Itself while triggering the event?

Why not just pass the sysId of the current record in Event parm and just do the rest scripting on the mail script itself?

 

Also other thing is that, how frequent is the BR triggering. By seeing your query, i guess the BR is gonna take some time to execute, this could also have an minor perf impact if the update is frequent.

 

-Regards,

Tenzin