You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have this situation: I'm trying to loop through some issues, ordered by assignee, and when the assignee is different from the last issue, I want to make an entry in the audit log (eventually will want to send an email)
I do a lookupissues with order by assignee (but i'm not sure the oreder by is working based on my results)
I create a variable LastUser to be "No User Given"
Then I branch on {{lookupIssues}}
I audit log the LastUser variable (and in the log, it shows it only ONCE)
Then I do an if to see if the {{LastUser}} == {{LookedupIssue.Assignee.DisplayName}} and if it does, I I audit log the {{LastUser}} and the {{LookedupIssue.Assignee.DisplayName}}
Then I create a variable LastUser to be {{LookedupIssue.Assignee.DisplayName}} which will be used as the comparison to the assignee DisplayName in the next iteration of the loop to see if I have yet another user.
But based on what I'm seeing, the LastUser is being set, but reverts back to "No User Given" at the beginning of the loop.
This is what I see in the audit log for showing the Last User at the beginning of the loop:
"Last User to Start is "No User Given" +++++"
And I see that once... shouldn't I see it multiple times in the audit log? Once for each iteration?
Then this is what I see prior to my if statement comparing the Assignee to the LastUser:
"Cur User is "Je Che", not Last user who is "No User Given" *****, Cur User is "Zhi Zho", not Last user who is "No User Given" *****, Cur User is "Alec Murry", not Last user who is "No User Given" *****"
So that looks like when I set the LastUser at the end of the loop, it didn't hold, because after I set it, I save it to the audit log and it looks OK:
Last User is now: "Je Che" !!!!! , Last User is now: "Zhi Zho" !!!!! , Last User is now: "Alec Murry" !!!!!
What am I doing wrong here?
I've included the screenshots of my Rule
Starting at the top:
Then inside the If statement:
Hi @Cash Coyne
You are seeing the behavior of branches...
So, what are the impacts...stuff that happens in a rule of type #2 goes out of scope after the loop. And so the create variable in your rule is brand new every time, and then thrown out.
There is an open suggestion to add a "wait until done" to branches, like for the Send Web Request. As that might dramatically impact rule performance I wonder if it will be done. Please look here to learn more: https://jira.atlassian.com/browse/AUTO-32
Anyways...
Without seeing your entire rule, I suspect you are trying to do something for each specific, distinct assignee found in the lookup. And so a work-around for that scenario is to use the distinct list operator, like this:
Kind regards,
Bill
{{lookupIssues.assignee.distinct}} is just what I need! TYVM!
Can I ask where you found this referenced? I looked in all the Jira documentation and I couldn't find the distinct described method anywhere except for a couple examples and only found them just now by knowing to look for the word "distinct".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad to learn that helped!
Regarding branches, I have learned through experimentation, posts from the Atlassian team, and references in the help, such as this one: https://support.atlassian.com/cloud-automation/docs/jira-automation-branches/#Ordering-of-branch-executions
For the distinct function, that is in the help on the smart value lists: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/
I recommend periodically re-reading the help on actions, conditions, branches, and smart values. Sometimes things appear there before they are released to prod :^)
And perhaps watch the articles in the automation product area: https://community.atlassian.com/t5/Automation-articles/bg-p/automation-articles
One final thing: most of the stuff I have learned about rules has been from experimenting to answer my own questions and those of others. The automation stuff is continually improving and so we cannot always rely upon the docs to stay current.
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.