Global variable in automation

Tony Georgiadis April 24, 2023

Hi all,

I'd like to create automation that updates an Epic's custom field based on a comparison of its child issues data.

Basically I'd like to achieve the following:

- When: An Epic is closed

- Then: It loops through the Epic's child issues and finds the latest resolution date 

- And: Updates a custom field (e.g. 'End date') on the Epic with the latest resolution date of the previous step

The problem I'm facing is that variables created in automation routines in Jira don't have global scope, so a variable that is set within an if branch is not visible outside of it.

Does anyone have any ideas about how I could solve this problem?

Thank you in advance,
Tony

2 answers

1 accepted

1 vote
Answer accepted
Fernando Eugênio da Silva
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2023

@Tony Georgiadis 

 

You don't necessarily need to use BRANCH if your trigger is a recognized Epic event.

See an alternative you can achieve to do this. Assume that I am using the Due date field as a reference, but in the end, you just change it to the field that makes sense to you

  • Trigger: Issue transitioned
    • To status -> Done
  • Condition:
    • Issuetype Equals Epic
  • Action:
    • create a variable
    • Smartvalue: {{issue.key}}
    • Name: epic
  • Action:
  • LookupIssue with the query:
    • "Epic Link" = {{epic}} ORDER BY duedate DESC

I'm using the Due Date field for the example, but you just need to change the field after ORDER BY for your date field. Use DESC to sort for the major to minor Date

  • Action: Edit Issue
    • Select your field and add the smartvalue: {{lookupIssues.first.duedate}}

In this case, you don't need the BRANCH because, as the Epic is the issue trigger for the Event, you only need to use the lookup feature to search for issues within the Epic itself.

If this doesn't work for you, share your rule details via images so we can help you achieve your goal.

Regards,

Fernando

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.
April 24, 2023

Good suggestion, @Fernando Eugênio da Silva 

You don't actually need to create a variable for the issue key of the Epic. Just use {{issue.key}} in the Lookup Issues JQL where you have {{epic}}.

Also note that if this is for a Team Managed project, in the JQL of the Lookup Issues action you need to use Parent rather than Epic Link.

I would also recommend adding a condition after the check that the trigger issue was an Epic to ensure that the Epic has child issues.

Screen Shot 2023-04-24 at 3.31.33 PM.png

Or add a condition after the Lookup to ensure that the Lookup found issues:

Screen Shot 2023-04-24 at 3.32.57 PM.png

0 votes
Tony Georgiadis April 25, 2023

That worked and it's clean. Thank you both, I appreciate the help! :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events