How to update custom field with value from linked issue

JAMJAR
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 18, 2024

We have 3 issues types: Task, Request, and Initiative. An Initiative is created first. I am trying to build an automation where when a Request is created that is linked to an Initiative it will fill in the custom Initiative Name field on the Request with the Summary from the linked Initiative. Otherwise, it will put in some default text liked "Requested Enhancement" or something similar. Important note: there will always only be up to 1 linked Initiative, any other linked issues will be other Requests or Tasks.

I have tried building this automation with a branch but it attempts to update the custom field on the linked Initiative which is not right. I have also tried to use an if/else component but I cannot figure out what combination of smart values or JSON to use to update the Initiative Name field with the Summary from the linked Initiative.

1 answer

1 accepted

1 vote
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.
December 18, 2024

Hi @JAMJAR -- Welcome to the Atlassian Community!

For a question like this, context is important for the community to help.  Please post the following:

  • what type of project is this (e.g., company-managed, team-managed, etc.), 
  • an image of your complete automation rule,
  • images of any relevant actions / conditions / branches, and
  • an image of the audit log details showing the rule execution.

Until we see those...

Once inside the branch, the rule tries to edit the branched-to issue(s).  As you want to edit the newly created Request instead, the rule could do this:

  • use the Lookup Issues action with JQL to get the data for the Initiative
  • confirm an issue was found with the Smart Values Condition
  • after the Request is created, use Branch to Most Recently Created Issue
  • reference the lookup results to edit the field

Seeing your rule images will confirm the specific changes needed.

Kind regards,
Bill

JAMJAR
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 18, 2024

Hi @Bill Sheboy 

It is a team managed project. Here is an image of the automation as it currently stands but as I said I have made many changes. I have removed my poor attempts at smart values and JSON and JQL so this is the entirety, there are no hidden details in the components.

image001.png

My thinking was perhaps I could use the JSON editor in that final edit issue fields component to pull in the summary from the linked issue of type Initiative. Would that work?

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.
December 18, 2024

Thanks for that information, and please try what I suggested using the Lookup Issues action with JQL to get the data needed: https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Lookup-issues

  • trigger: issue created
  • action: re-fetch issue
  • condition: issue type equals Request
  • condition: linked issues present relates to
  • action: lookup issues to get the Initiative with JQL
  • smart values condition
    • first value: {{lookupIssues.size}}
    • condition: equals
    • second value: 1
  • action: edit issue, to update your field in the Request with {{lookupIssues.first.yourFieldFromTheInitiative}}

 

Like JAMJAR likes this
JAMJAR
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 18, 2024

That worked perfectly! Since I wanted this to do something else if there is not linked Initiative I actually made it an If/else component. In the If it checks if there is a linked issue of relates so, and further uses JQL to check if some of those linked issues are type Initiative. Then used google to find out how to write the JQL to check for linked issues of type Initiative for the lookup component. Then used the smart value you specified to edit the Initiative Name field. And in the Else branch just had it update to the default value I specified above. Tested the 3 cases I can imagine (Request with no links, Request with links to non-Initiatives, and Request with link to an Initiative) and all 3 went as expected. Thank you for your help!!

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.
December 18, 2024

Awesome, and well done adding the extra steps needed!

Suggest an answer

Log in or Sign up to answer