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?
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:
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
Thanks Bill, your suggestion worked : https://confluence.atlassian.com/jirakb/automation-to-send-email-only-once-per-assignee-1310985609.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 automation
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.