Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira Automation - If statement not working

Jonathan Bobo February 23, 2025

Hello,

I've tried everything and it seems i am missing something critical. I can't get my if statement to work properly in an automation.

I am using a For each branch where i set the smart value to 

{{lookupIssues.assignee.distinct}}

 

I have been told that distinct only returns a string and not an object, in this case the string would be the accountId.

Then, i have a Send Email action. In the body content, i am using this and the If never matches :

{{#lookupIssues}}

{{#if(equals(assignee, fields.assignee.accountId))}}

[{{key}}|{{url}}] - {{fields.summary}}

{{/}}

{{/}}

 

At some point i realized that i can actually consider assignee as an object and assignee.emailAddress does work. But even then, when i use this statement : 

{{#if(equals(assignee.emailAddress, fields.assignee.emailAddress))}}, it never matches while it should. Plus, when i simply print assignee.emailAddress i can see that it outputs the expected email address. 
What drove me crazy is that if i do this, the if statement actually works (of course with a valid email)! 

{{#if(equals("myEmail@address.com", fields.assignee.emailAddress))}}

I was told to use unique in the for each smart value, but it doesn't seem to work (the send email action never triggers)

Does anyone has a clue?

3 answers

1 accepted

2 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2025 edited

Hi @Jonathan Bobo -- Welcome to the Atlassian Community!

For a question like this, context is important for the community to help.  Please post the following:

  • what version of Jira are you using: Cloud, Server, or Data Center;
  • if using Cloud, what type of project is this: company-managed, team-managed, etc.;
  • an image of your complete automation rule in a single image for continuity;
  • images of any relevant actions / conditions / branches;
  • an image of the audit log details showing the rule execution; and
  • explain what is not working as expected and why you believe that to be the case.

Until we see those...

The scenario you seem to be describing is for some issues, send one email for each assignee with their issues.  This is a common request, and here is a knowledgebase article describing one possible solution: https://confluence.atlassian.com/jirakb/automation-to-send-email-only-once-per-assignee-1310985609.html

Next, the list distinct function returns distinct objects, and the returned value is not just text.  In the expression you show, it would return a user, including all of its attributes.

Next, it appears you have an advanced branch over the values from {{lookupIssues.assignee.distinct}} and are naming the branch variable "assignee".  Using a variable with the same name as other smart values will certainly cause rule steps (and people) to be confused, possibly colliding with other smart values.  I recommend always adding a prefix to variables to prevent this problem, such as with varAssignee.

Finally, when iterating over a list, such as {{#lookupIssuess}} do something {{/}}, only data from the list scope {{lookupIssues}} and lower is visible.  No outside data is visible, and so your apparent branch variable {{assignee}} both cannot be seen and is confused with the lookup fields (as described above).

Kind regards,
Bill

Like Bill Sheboy likes this
0 votes
Jonathan Bobo February 24, 2025

Hello @Vishal Biyani , @Bill Sheboy ,

 

First of all thank you so much for answering me so fast. I really appreciate the support.

Here is my automationjira-automation-1.png

jira-automation-2.png

With what Bill provided i think i now understand what's going on. 

you mentionned this and I believe that is it : Finally, when iterating over a list, such as {{#lookupIssuess}} do something {{/}}, only data from the list scope {{lookupIssues}} and lower is visible.  No outside data is visible, and so your apparent branch variable {{assignee}} both cannot be seen and is confused with the lookup fields (as described above).

That being said, i'm looking at the link you shared and i think this is definitely going to cut it. I'll try and confirm here!

 

Thank you so much

0 votes
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2025

@Jonathan Bobo 

are you missing a # before lookupIssues?

{{#lookupIssues.assignee.distinct}}

 

Can you share the SS of your automation so that it is clear what you have created so far?

Also, share the audit log showing the values in assignee variable. 

Just to ensure that this smart variable is not clashing with JIRA defined values, can you rename it to something like varAssignee and try?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian community, university, on demand, transition to jira cloud

Transition to Jira Cloud

Switch to Jira Cloud with Atlassian University! Explore new navigation, issue views, and Cloud features like team-managed projects and automation. Tailored for Data Center users & admins, these courses ensure a smooth transition. Start your journey today!

Enroll now
AUG Leaders

Upcoming Jira Events