Compilation of Smart Values within Linked Tasks
Asked by Bryan Harmon (Lost Boys):

Hello there! I'm attempting to compile a list on a top-level task and running into an issue with automation.

For context, this top level task has several linked tasks, each with a Smart Value "Patch Note."

My goal with the automation flow is when its transitioned to an In Progress state, it enumerates through each linked task and compiles a list of Patch Notes from each linked task.

The issue I'm encountering is that I'm unable to access the latest comment of the root top-level task via any Smart Value I've tried to edit it with the compiled list of notes.

![comment layout.png](https://community.atlassian.com/t5/image/serverpage/image-id/265834i1AAF67BEBC0278B0/image-size/large?v=v2&px=999 "comment layout.png")

I've tried using {{triggerIssue.comments.last.id}}, but this yields "No comment to edit."

Thanks in advance for any information you can provide.


Answers:
author: Bill Sheboy
body: Hi Bryan,

Looking at the image of the rule you posted in the question, I wonder if it works as you expected regarding created variables: **are you expecting that created variable to be updated and usable after the branch?** If so, please note...

1. Branches on *one-and-only-one-thing* (e.g., branch on current issue, parent, etc.) get run in-line, as if the branch did not exist / alter the flow.
2. All other branches which *could-be-more-than-one-thing* (e.g., branch on JQL, linked issues, etc.) are run asynchronously and in parallel. Issue updates work, as expected, and persist. Other things which happen in the branch stay in there, and go out of scope afterwards. And...there is no guarantee of when the branch will complete...up to the very last step of the rule itself.

What this means for your apparent rule is that a variable created inside of a branch of type #2 will go out of scope with each loop. The results are not preserved and carried forward for each loop...or after the branch completes.

The same is true for branches of type #1, with a special exception if a variable is created before the branch and recreated inside with the same name, the value is updated. For example:

* ...
* action: create variable with name *varMyVariableName* and some value
* branch: on current issue (or another type#1 branch
  * ...
  * action: create variable with the same name *varMyVariableName* and some updated value (shadowing the old value)
  * ..
* ...after the branch, the updated value of *varMyVariableName* is available

Kind regards,  
Bill


author: Darryl Lee
body: Hi [@Bryan Harmon (Lost Boys)](/t5/user/viewprofilepage/user-id/5256560) -

Wouldn't editing the top-level task's latest comment possibly be a problem if somebody had come along and made a comment on that task?

I would just add the list of patches as a new comment.

I ***believe*** your rule could be much simpler if you do something like this:

![Screenshot 2023-07-21 at 10.03.00 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/270470i524455FDA14D2186/image-size/large?v=v2&px=999 "Screenshot 2023-07-21 at 10.03.00 AM.png")  

I basically copied the work from John here: <https://community.atlassian.com/t5/Jira-Software-questions/Automation-How-comment-linkedIssues/qaq-p/1555922#M112511>

comments: author: Darryl Lee
body: Whoops, reread your original post - you'd want to change the trigger to when it transitions to "In Progress".


author: Bryan Harmon (Lost Boys)
body: It's not shown in the screenshot (it's above) but the trigger is for In-Progress and the automation is creating the comment in question so thankfully I don't have to worry about a user editing it in the meantime!

I'll give it a shot and mark as Answered as soon as I'm done. Thank you!


author: Darryl Lee
body: Ahhhh, ok that makes a lot more sense.

Yeah, let me know how it goes.