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

Conditional logic in email template for LookupIssues and Smart Value

Julian Petrich August 23, 2023

I want to create a Jira automation rule which sends out an email to each assignee based on a JQL query. The email should only contain a list with all issues assigned to the recipient.

Therefore, I created this automation:

Screenshot 2023-08-24 at 1.30.50 pm.png

And my email template looks like this:

{{#lookupIssues}}
{{if(equals(issue.assignee, issue.distinctAssignee))}}
<a href="https://jira-url/{{key}}">{{key}} {{summary}} </a> <i>[{{status.name}}]</i>
{{/}}

 

Problems:

  • The "if" statement is always true so every person I sent this email to gets a full list of all issues based on the JQL query.
  • Sending out the email, it prints "true" in front of each issue I am listing.

 

Please let me know if you need any further information.

 

Help is much appreciated. Thank you!

 

1 answer

0 votes
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2023

Hi @Julian Petrich -

How are you creating your list of "distinctAssignees"? Because as far as I know that is not something you can get from a JQL lookup.

The other problem is that even if you had a way to create a list (manually using split()? API call?), the problem is you cannot reference a Smart value from inside of a list iterator.

In other words, {{distinctAssignee}} cannot be accessed from within the {{#lookupIssues}} iterator.

I think the approach you'll want to take is detailed here:

So you would put your Lookup inside of your Smart value branch, and modify your JQL to be:

project = 11844 AND type="finding" AND resolution is empty AND assignee={{distinctAssignee}}

Then all of the {{#lookupIssues}} should be the ones you want for each assignee, and you don't need to use if to filter them at all.

Julian Petrich August 23, 2023

Hi @Darryl Lee 

Thank you for your help! That makes sense.

This is how I am getting my distinct assignees but maybe that's not even the best way to do it:Screenshot 2023-08-24 at 3.19.56 pm.png

 

I have tried your suggestion with another JQL query inside my Smart value branch which worked for a small amount of assignees. Once I changed the scope to all the assignees I got this error message:

Payload for custom variable is too large, try reducing the amount of data stored in your custom smart variable.

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2023

OH SHOOT, there is a distinct. Nice!

Huh. That is a weird error. When you say you had a small amount of assignees, do you mean you scoped the first Lookup to only include certain assignees?

I guess first off, how many issues are we talking about in the original query?

And how many distinct assignees are there?

(You could log {{lookupIssues.assignee.distinct.size}} to find out.)

Like Rick Westbrock likes this
Julian Petrich August 24, 2023

Yeah, so in the initial lookup I had only myself and a colleague as assignees to test it the rule which worked perfectly.

The query has 142 issues and 24 distinct assignees.

The main reason to have this rule is that we close and open issues going into this query. Hence, I don't want to update and send emails manually.

 

My current workaround is to include a filter into my email with the query above and "assignee=currentUser()".

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2023

Bizarre. The custom smart variable the first time around is 24 assignees.

So you started getting the error when you added another Lookup for:

project = 11844 AND type="finding" AND resolution is empty AND assignee={{distinctAssignee}}

So like, 24 times, it should run that query and each time it should return a set of issues that is easily < 142, so... I don't know.

Maybe this is a question for Support?

Julian Petrich August 24, 2023

Yes, correct. So my second lookup was within the new branch. I was surprised as well.

Sure, I will reach out to the support then.

Thanks a lot for your support @Darryl Lee it's good to know that it should work at least.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events