Send email notification to user in custom field using Lookup issues

Danilo Simic
Contributor
May 11, 2023

Hello everyone.

We have a custom field called "Procurement Initiator" which is a user picker field. Is there a way to send a list of tickets to the user selected in the mentioned field?
To be more specific I would like for each user selected as Procurement Initiator to only get tickets where their account is present.

Here is how the rule is currently setup:1.PNG

NOTE 1: There is no JQL in the first component of the rule (Scheduled)
NOTE 2: If I were to add an email in the "To" section of the Send email component, the rule would work and would send a list of tickets with all tickets that satisfy the provided JQL in the Lookup issues component.

 

It is not possible to create separate rules for each Procurement Initiator since more than 100 users can be selected as one.

 

Thank you for the help.

 

1 answer

1 accepted

1 vote
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

Hello @Danilo Simic 

Take a look at the Answer from @Kian Stack Mumo Systems  on this post.

After the Lookup you need to add a branch to loop over the unique Procurement Initiator values (where the answer shows cars). Within the branch you do another Lookup for issues for each Procurement Initiator, and send an email with those results.

Danilo Simic
Contributor
May 12, 2023

Thank you for the suggestion. I took a look but I am failing to make it work.

I am afraid I am missing something trivial. Here is the rule setup and what the error looks like in the audit log:

1.PNG

 

The rule is made up of the following modules:

  1. Schedule module - No JQL present

  2. Lookup issues with the following JQL: created <= -30d and status not in (Approved, Rejected) and "Procurement initiator[User Picker (single user)]" = 63aed024082abdd71bb57d41
    As you can notice I have included only 1 user account, this is my account so that I do not send email notifications to other users anymore.
  3. Branching module with the following smart value: {{lookupIssues.Procurement initiator.value.join(",").remove("[").remove("]").replace(", ",",").split(",").distinct}}
  4. Lookup issues with the following JQL: "Procurement initiator" in ({{ProIni}})
  5. Send email module - right now it is trying to send an email to the lookup value but I have also tried adding {{ProIni}} and the field itself which did not work. When I added my own email I got an email but no issues were present in the list
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

The easier problem to address is the email issue. For the Send Email action you need to provide the email address for the user. To do that for a value from a single user picker field you would append .email to the smart value; i.e. {{issue.assignee.email}}

The more complicated issue is the smart value in your branch. Where did you get that code? I have seen things like that but haven't actually used it. I think it is incorrect. When I try to use it myself I'm finding that it provides no value back to me.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

This works for me. I used the Assignee field for testing.

Screen Shot 2023-05-12 at 3.23.52 PM.png

 

Step 1:

Screen Shot 2023-05-12 at 3.24.35 PM.png

 

 

Step 2:

Screen Shot 2023-05-12 at 3.24.43 PM.png

 

Step 3:

Screen Shot 2023-05-12 at 3.24.51 PM.png

 

Step 4:

Screen Shot 2023-05-12 at 3.24.59 PM.png

Danilo Simic
Contributor
May 15, 2023

I found the code on the community post you provided me with in your first reply.

 

I tried changing the automation rule to match your setup:

1.PNG

2.PNG

customfield_10046 is the "Procurement initiator" field

3.PNG

4.PNG

 

With this rule setup I get an error saying that there is no email provided:

5.PNG

 

Judging from the audit log, the lookup module finds the correct issues.

Am I missing something obvious? Did I maybe not write the customfield property correctly? 

 

Thank you for the help, sorry for being difficult.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 15, 2023

You need to be using the field name, not the variable name, in the smart value to use in the TO field for the Send Email action.

Danilo Simic
Contributor
May 16, 2023

I got the same error

1.PNG2.PNG

 

I also tried typing {{lookupIssues.first.Procurement initiator.emailAdress}} in the "TO" section of the Send email component and got the same error like in the screenshot.

 

Then I tried with the following changes:

3.PNG

The error message is a bit different this time:

4.PNG

 

I do not understand why the error message says that there is no issue present when the 2 lookup modules find issues without any problems.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 16, 2023

You have misspelled the smart value in the TO field. I'm sorry I didn't notice that. emailAddress needs to have two "d"s

{{lookupIssues.first.Procurement initiator.emailAddress}}

Danilo Simic
Contributor
May 17, 2023

I am such a fool. Now the rule works great. Thank you very much for the help.

 

Side question, if I wanted to also edit those ticket for which I just send an email, how would I approach that?

Danilo Simic
Contributor
May 17, 2023

Never mind my last side question. It is not needed and will not be needed.

 

Once again, thank you very much for the help.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events