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

Branch to destination issue from inside a branch.

Nik Rogul August 13, 2024

Hello!

I am creating an automation that sums up all the work hours logged in all items under an initiative and add the number to a custom field in Jira Product Discovery idea.
My work-items tree looks like this:
Initiatives
Epics
Stories
Sub-tasks.
So I created an automation that runs in a branch on all the children of an initiative and sums up the work hours - this works good.

image.png
So inside a branch I aggregate the hours to the totalWorklogHours variable, but how do I add the value of the variable to the destination issue's custom field?
Normaly you would branch to destination issue, but you cannot branch from inside a branch.

Any creative ideas?
Thank you.

2 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.
August 13, 2024

Hi @Nik Rogul 

As @Trudy Claspill a branch like what you show cannot increment a created variable: as the branch's parallel processing happens, the variable will repeated go out of scope (and be destroyed)

 

I believe your scenario is possible in one rule, with some assumptions:

  1. your link to the JPD Idea uses the default linking to the Initiative,
  2. all of the issues below the Initiative have time you want to sum, and
  3. that there are fewer than 100 issues total below the Initiative.

 

This could be done using the JQL function parentEpic() to gather the issues under the epics, form a dynamic JQL statement, and then lookup the issues to sum them all.  Perhaps something like this, with most likely a global scope automation rule, configured by your Jira Site Admin:

  • trigger: Issue Linked (with the type linking to the Idea)
  • condition: issue type is Initiative
  • condition: is another condition needed to check the project for the initiative???
  • action: lookup issues with JQL to gather the Epic children of the Initiative
issueType = Epic AND parent = {{triggerIssue.key}}
  • action: lookup issues with dynamic JQL to gather all of the issues below the initiative (This result will also include the Epics; please see the note about assumption #2 below.)
parentEpic IN ( {{lookupIssues.key.join(", ")}} )
  • branch: to the JPD idea
    • action: edit issue to set the field to the sum of the time for the lookup results

 

Please note well assumption #2: if you have other rules / methods which are already summing time at other levels, that will need to be handled to prevent duplicating sums.

 

This approach will only sum the values when the Initiative is linked to the Idea.  To make updates when time is tracked for any issue in the tree, this is more complicated and requires more rules.  An alternative would be to use a scheduled trigger to periodically update the field in the Ideas. 

The solution selected depends upon how frequently you want the Ideas updated.  Using the scheduled rule has the advantage that it can be run manually to force an update, when needed.

 

Kind regards,
Bill

Trudy Claspill
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 13, 2024 edited

I have one change to suggest.

Given that @Nik Rogul indicates the Premium subscription is being used, and assuming that the Issue Type Hierarchy has been used to make Initiatives parents of Epics, then the Lookup Issues JQL can be simplified to a single action using the portfolioChildIssuesOf()

https://support.atlassian.com/jira-software-cloud/docs/search-for-advanced-roadmaps-custom-fields-in-jql/#Child-issues

And if only the Story level issues have time that should be included in the sum then the JQL would be

issue in portfolioChildIssuesOf("{{issue.key}}" and issuetype in (Story))

 

UPDATED: fixed the missing parentheses at the end of the JQL.

 

Like • Bill Sheboy likes this
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.
August 13, 2024

Thanks, Trudy! 

For Premium license customers, that would reduce this to use one Lookup Issues action rather than using the dynamic, two lookups approach needed for other license levels.

FYI, there appears to be a missing closing parenthesis in your example for the JQL function call.

Like • Trudy Claspill likes this
Nik Rogul August 13, 2024

Bill, thank you so much!
Your solution works exellent.
Then I went to find out how to count children of an initiative to see if a limitation of 100 will be a problem for us, and figured out that there is another helpful function in my case:
I can use lookup for JQL "key in portfolioChildIssuesOf({{triggerIssue.key}})" and this will return all the children of an initiative eliminating the need for two lookups.
But I still learned a lot.

Can you please elaborate on the 100 child issues condition? Why is this a limitation? Will it be a limitation if I use the portfolioChildIssuesOf function?

As of other concerns in your reply:
- I am an admin, so the rule is global (to be exact: multi-project)
- Yes, I am aware that this rule will only add hours to an idea upon linking. I will have another rule that deletes the hours if initiaitve is unlinked. Also the rules will cover if epic or a single stoy is linked/unlinked 
- And I have a set of rules that append the work hours in idea if new hours logged for an inssue that is linked (or one of its parents are linked) to idea. Here I have a problem that will be a subject of my next question in the community.


Nik Rogul August 13, 2024

LOL! I see that Trudy wrote about Portfolio function too.

Trudy Claspill
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 13, 2024

The limit of 100 is a limitation on how many results can be returned by the Lookup Issues action, as documented here:

https://support.atlassian.com/cloud-automation/docs/automation-service-limits/

There is no specific explanation other than "to ensure the performance of your instance is maintained."

Like • Bill Sheboy likes this
Nik Rogul August 13, 2024

I see. Thank you, I need to see if we exceed the amount normally.

 

2 votes
Trudy Claspill
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 13, 2024

Hello @Nik Rogul 

Which issue do you want to update? Which issue is the "destination issue"?

You started with an Initiative and branched to its child Epics. In the branch you are summing up the Time Spent of the child Stories under each Epic. Do you want to save that information to the Epic?

And then do you want to sum up all the time you wrote into the Epics and put the sum into the Initiative?

You may have some trouble accomplishing that in a single rule if that is your goal. The processing inside the branch will happen in parallel to any other actions you add to the rule. You can't depend on the branch processing finishing before the next steps in your rule are executed.

You could add a Delay action after the branch to pause the rule for the amount of time you think it would take to complete all that processing. Then add a Lookup Issues action to retrieve all the child Epics of the Initiative, and sum up the Custom Time Spent information you have added to them. However, that also might be a problem because the Sum function does not necessarily work with all custom fields in a Lookup Issues results set.

I have no experience with Jira Product Discovery and automation, so I can't address that part of your requirement at all.

Rolling up time spent information is a tricky endeavor when you are going through multiple hierarchical layers. You may want to consider if a third party app can help. You can see the discussion in this other post for some considerations of the challenges.

https://community.atlassian.com/t5/Jira-questions/Roll-up-hours-from-Subtask-to-the-Theme-level/qaq-p/2615704

Nik Rogul August 13, 2024

Thank you for the reply.
When you use "Issue linked"  trigger, one side of the link can be referred by {{issue}} and the other side of the link is referred by {{destinationIssue}}
In my case an initiative is linked to idea, so initiative is an issue, and idea is a destination issue.
So I aggregate the work hours if the initiative (i.e. {{issue}}) and need to update the hours in a field of idea (i.e. {{destination issue}}).
Normally, when you work with link trigger, you can access the descination issue by branching to it, but when you are already in the branch, you cannot create another branch.
Normal "Edit issue" action will not work because it works on a current issue, i.e. on the initiative.

Jira product discovery is no different from Jira Software when it comes to automation as Ideas are normal Jira issues and everything that is applied to Jira works there.

I am aware that the branches run in separate threads, so I need to do the update in the branch itself, and that is exactly the problem. Unfortunately I cannot use variables too because there is no way to update a variable value.

So I am looking for a way to address in a branch an issue that is not this branch's current issue.




Trudy Claspill
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 13, 2024

Hello @Nik Rogul 

Thank you for clarifying your destination issue reference. I am familiar with the {{destinationIssue}} smart value when using the Issue Linked trigger.

You already have a condition to check that the trigger issue {{issue}} is an Initiative. I suggest that you add a second condition to confirm that {{destinationIssue.type.name}} is the issue type to are targeting (Idea).

Can you address these other questions I posted, to ensure that we are understanding what values you are trying to sum up in total?

You started with an Initiative and branched to its child Epics. In the branch you are summing up the Time Spent of the child Stories under each Epic. Do you want to save that information to the Epic?

And then do you want to sum up all the time you wrote into the Epics and put the sum into the Initiative?

Your branch is summing the information for child issues under each Epic that is under the Initiative.

This is not yet producing a sum of the information from ALL child issues under ALL Epics under the Initiative into to one grand total for the Initiative. Is this the goal you are trying to achieve?

 

Nik Rogul August 13, 2024

There is no need to validate that the destination issue is an Idea because in the link trigger the link type is set to "Polaris issue link" which is a link type specific to Ideas ("implements" and "implemented by")

Now, as of summing up. I did not find a way to sum all work hours for an initiative as you can do for an epic.
For epic it is easy by looking up all the issues with ParentEpic function and then using 
lookupIssues.timetracking.timeSpentSeconds.sum
Works great!

So i am running in a branch on all the children of an initiative (i.e. epics) and each branch sums up work hours for one specific epic.
I have no intention to write the sum of work hours to the epic itself, I need to add this sum to a field in the idea, so basically the idea will have a total work hours spent for the initiative that was linked to it.
And if there are 3 initiatives that are linked to an Idea, so to have a sum of work hours spent in all 3 of them by adding the hours for an initiative once it is linked.

Trudy Claspill
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 13, 2024

Thank you for that clarification. Now I understand your thought process on how you want to achieve your requirement.

I see that @Bill Sheboy (who is my go-to-guy when it comes to Automation rules) has provided an answer. I'll review that first and then see if I have anything to add.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events