Forums

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

copy the category field from parent when a subtask is created

Erik Mathijs
Contributor
September 4, 2023

Hi,

I want to create an automation rule in a jira work management project 

when a subtaks is created -> copy the category field from the parent issue.

Can anyone help me with this ?

Thanks in advanced !

2 answers

1 accepted

5 votes
Answer accepted
Tomislav Tobijas
Community Champion
September 4, 2023

Hi @Erik Mathijs 

You can construct something like this:2023-09-04_09-42-40.png

You'll need to use Advanced fields section within Edit issue action and you can use the following JSON:

{
"fields": {
"Category": { "value": "{{issue.parent.Category.value}}" }
}
}

This should copy any "Category" value that is set to a parent issue (if it exists).

2023-09-04_09-38-16.png

Hope this helps.

Best,
Tom

Erik Mathijs
Contributor
September 4, 2023

Thanks Tom !

Like Tomislav Tobijas likes this
Justina Bülow September 11, 2023

Hi all, 

I am facing the same problem and when using the JSON, I get the following error message: Additional fields contains invalid field(s) in 'update' or 'fields' section: Category

I would appreciate some assistance with this case. 

Tomislav Tobijas
Community Champion
September 11, 2023

Hi @Justina Bülow 

Can you copy Additional fields section content and maybe paste screenshots from the site and where the problem appears?

Also, can you confirm you're in business/Jira Work Management project? Additionally, from where are you creating sub-tasks?

Cheers,
Tom

Justina Bülow September 12, 2023

Hi,

Yes, it's a Jira Work Management project and a team-managed project. 

The subtasks are created by automation and both parent and subtasks contain the category field. 

The only Category field I can choose is showing the wrong values, so it can't be the correct field. 

I believe we messed up something with the field, but I'm unsure how to solve it.

 

Thanks for your support. 

Best,

Justina

Bildschirmfoto 2023-09-12 um 10.15.19.pngBildschirmfoto 2023-09-12 um 10.12.29.pngBildschirmfoto 2023-09-12 um 10.11.35.pngBildschirmfoto 2023-09-12 um 10.11.26.png

Justina Bülow September 12, 2023

PS: I believe the field is preset, as I can't change the field at all.

 

Bildschirmfoto 2023-09-12 um 10.27.16.png

Tomislav Tobijas
Community Champion
September 12, 2023

Hi @Justina Bülow

I think I've managed to replicate this error you're experiencing.2023-09-12_12-54-27.png

Basically, this might happen in case you have more than 1 field named "Category".
From the "Edit issue" action that you've attached here, I suspect that's the case (as you cannot, at the moment, select the system "Category" field from that dropdown).

Can you please navigate to Settings > Issues > Custom fields and check if that's the case? It should look something like this (note that the highlighted field is the custom field created by a user, and the one with "Locked" status is a system field):

2023-09-12_12-55-05.png

In order to 'fix' this - to be able to use the provided JSON within the automation action, please rename all custom fields that are named "Category".

If that did not help, or if you mustn't/shouldn't rename those fields, I can try to find some other solution that actually uses system field ID instead of a name.
Just a note - I've tested this on a company-managed project.

Justina Bülow September 13, 2023

Hi, 

Thanks for the suggestion and quick answer. Unfortunately, I can't and think I shouldn't change this field, as it's supposed to be a preset field and those I can't change. 

It would be great if you could find a solution to use the field ID. I tried it, but I'm unsure what the JSON needs to look like. 

Tomislav Tobijas
Community Champion
September 13, 2023

Then, you can basically use the following format customfield_ID instead of "Category" string/name.

To find the ID of the system "Category" field navigate to Custom fields page under Jira administration and search for the term "category", and follow the steps below:

  1. Find the system "Category" field in the list (the one with type = Unknown and where there is a small label "Locked" next to a field name).
  2. Click on the 'more' button next to a field name.
  3. Hover over any of the available options.
  4. At the bottom of the page, you'll see a URL to which you'll be redirected once you click the link, and in the URL you should see a field ID.

Once you find the ID, go back to the automation rule and just replace "Category" string with customfield_ID where the ID is the number you've found in the step 4.cf_ID.png

I've tested this by having 2 fields named "Category" in the custom fields list, and automation worked as expected. Also no errors/warnings were stated when trying to save/publish the rule.

Note that it might be recommended to not have two or more fields with the same name (whether we are talking about system or custom fields) - due to easier administration and also to not confuse end users. That's why I suggested renaming the custom field in my previous answer.

Like Maria Kutkina likes this
Justina Bülow September 14, 2023

Hi @Tomislav Tobijas

 

Thanks a lot for the support. Is there any chance that you can post the JSON as text so that I can copy it? I'm receiving the following error message "Error while parsing additional fields. Not valid JSON."

 

Sorry, for asking again, and thanks a lot! 

Tomislav Tobijas
Community Champion
September 14, 2023

No problem. Here's JSON as text:


{
"fields": {
"customfield_10123": { "value": "{{issue.parent.customfield_10123.value}}" }
}
}


Note that, sometimes, during the copy/paste process, quote marks might automatically change (due to OS config. or something else). If that happens, try to replace all symbols (including parentheses) with new ones by typing them manually.

👉 Also, as stated above, replace ID 10123 with field ID from your site.

Justina Bülow September 21, 2023

Hi @Tomislav Tobijas

 

Thanks for the help. I finally made it work. 

 

Best,

Justina 

Like Tomislav Tobijas likes this
0 votes
Fabio Racobaldo _Herzum_
Community Champion
September 4, 2023

Hi @Erik Mathijs ,

please take a look to the following tutorial https://www.youtube.com/watch?v=klwQA9cwBfU, it should help you on that

Fabio

Erik Mathijs
Contributor
September 4, 2023

Hi @Fabio Racobaldo _Herzum_ ,

This video is helpfull but the category field in jira work management seems to be a special field.

I can't select it in the edit field action screenimage.png

Fabio Racobaldo _Herzum_
Community Champion
September 4, 2023

please share a screenshoot about that field on creation

Erik Mathijs
Contributor
September 4, 2023

In jira work management i have the field category

image.png

i want to copy the category field from the parent to the subtask when a subtask is created.

In the automation rule i create a branch

In the choose field to set the category field is not available

image.png

 

and it is also not available on the copy field from parent (for getting this i selected another field to try getting the parent field category

image.png

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