Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

In Jira automation, how to 'inherit' fix version in Advanced?

Niklas Malmberg
Contributor
March 30, 2023 edited

Hello,

I want to create an Jira automation rule that will propagate down fix version information from parent to child, for example from Story to Subtasks. At the same time, I want to copy down labels from parent to child as well. 

In my example, I have these definitions in the Story:

"Fix versions" = ["8.2", "8.x"] (two strings)

"Labels" = ["hello", "goodbye"] (two strings)

I have read several posts which looks very similar to my case, like https://community.atlassian.com/t5/Jira-questions/How-to-make-sub-task-in-a-story-or-task-inherit-fix-versions/qaq-p/2109235

Unfortunately, there where not enough for me to understand how I should solve my problem, however similar it looked :(

I know how to set up the rule trigger I want, I can branch out over the subtasks correctly, but I'm having difficulties how to to do the assignment of the field/array. (I believe this perhaps has to do with fix versions being a multi-value field)

Questions:

1. Why is there no 'copy from trigger issue' option in Edit issue, like there already exists for labels field? (this helped my propagate down Labels information, half the task solved).
Skärmbild 2023-03-30 195916.png

2. Since the easy assignment was not enaugh, I had to go to Advanced. Here, should "update" + "add" be used, or "fields"?

3. Since the target field is an array, can it be addressed by the name "Fix versions" anyway? (I found no other allowed syntax, but ...)

4. Since the source field is also an array (the parents information in field 'Fix versions'), how should it be referred to? 

5. I've seen several different ways to access an array and also to transform the content, asJsonString, asJsonStringArray etc. Do I need to transform the content of the source data at all, when I really just want to copy (or add) the whole source field (whole array content) into the target array? 

 

What I currently have tested (which fails with JSON error, as shown in audit log for automation) is this code snippet:

Skärmbild 2023-03-30 200919.png

I hope someone here can help me understand what I'm doing wrong.

Thanks in advance
//Niklas

1 answer

1 accepted

3 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.
March 30, 2023

Hi @Niklas Malmberg 

First thing, there is a copy for fields like Fix Version...it is just a bit tricky to find it.  This can be done without the advanced edit JSON when you want to replace the value.

  • add your Issue Edit action
  • select your Fix Version field
  • select Copy at the right side under the ...
  • then select the field to change the option to Copy from Trigger Issue

If you want to add values from the Story to the Subtask's existing values, this is a more complicated solution which does require using the advanced edit JSON for fields like Fix Version to add values using update.

 

Next, this scenario often requires multiple rules, with different triggers.  And so the edits (in the copy-from) may be different.  Please consider at least:

  • a new subtask is added to an existing issue
  • a subtask changes to a new parent issue
  • the fix version for an issue changes (and any other fields you want to cascaded to children)

Kind regards,
Bill

Niklas Malmberg
Contributor
March 31, 2023

Thanks Bill, that 'hidden' way to use the more simple way to copy Fix versions from trigger issue worked like a charm!

Skärmbild 2023-03-31 091706.png
Funny that Atlassian has implemented the UI so differently for these two fields, but at least now I've found a new way to search for built-in functionality. 

Much appreciated ! 

Just out of curiosity, how could I have implemented the same 'copy Fix version from trigger issue' in JSON code?

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.
March 31, 2023

I am glad to learn that helped.

In that link I provided, documentation walks through the specifics for updating fields with JSON.  The technique you use depends on if you want to replace or add to the existing values.  Let's assume you want to replace the values in the Subtasks with those from the Story.

The simplest syntax for this is to use the fields shortcut , as shown below.  Again, let's assume the trigger issue is the Story and you want to edit a Subtask...which you have branched to.  Let's also assume there is only one value for the fixVersion.

In the rule's Issue Edit action, you would select More options to add JSON.  When using this method, do not select the field from the dropdown at the top of the action, as you will change it with JSON.

{
"fields": {
"fixVersions" : [ { "name": "{{triggerIssue.fixVersions.first.name"} ]
}
}

The fixVersions field is a list and can contain multiple values.  So we add the first function to specifically select that item as we are assuming there is only one.

When you have multiple values to copy/edit, the JSON needs to be a bit more dynamic.  Atlassian has added some other functions to help with that, and you can learn more about them here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/

roberto
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!
June 13, 2023

Hey @Bill Sheboy and @Niklas Malmberg :)

Regarding:

If you want to add values from the Story to the Subtask's existing values, this is a more complicated solution...

If I understood correctly this can be achieved in the "Copy from" dialog too, they have added a "Add to existing values" checkbox.

Like • 2 people like 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.
June 14, 2023

Hi @roberto -- Welcome to the Atlassian Community!

Yes, and...that option did not exist originally for rule actions.  Instead the changelog was needed to address this.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events