How can I copy a cascading select value with Automation for JIRA?

andreas
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.
May 9, 2017

I'd like to copy a cascading select from one issue to another. This requires the Advanced section in edit issue, but not sure what to put into it?

7 answers

1 accepted

23 votes
Answer accepted
andreas
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.
May 9, 2017

Lets assume our field is called "Sample Cascade" here.  The advanced JSON block you'll need to copy this in your edit issue action is:

{
  "update": {
    "Sample Cascade": [
      {
        "set": {
          "value": "{{triggerIssue.fields.Sample Cascade.value}}",
          "child": {
            "value": "{{triggerIssue.fields.Sample Cascade.child.value}}"
          }
        }
      }
    ]
  }
}

Here's an example rule that copies from the parent issue to all of its subtasks:

copy-cascading-select.png

Alex Shmakov May 21, 2019

Hi
Can you please add this solution to documentation?

https://docs.automationforjira.com/

Rob Horan
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.
November 18, 2019

How can I explicitly set a value for a subtask I am creating, rather than copy it?

Jordon Ellis August 28, 2020

Hey, just for anyone else. 

 

You can simply paste in the string value of the entry into the section where the trigger is ran. You would replace {{triggerIssue.fields.....}} with "Your Value".

Like Liam Green likes this
Liam Green
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.
October 22, 2020

@andreas @Jordon Ellis 

I've been trying for an hour to do this!

Thank you!!

Abin Jacob December 10, 2020

@andreas 

Is it possible to inherit only the first value of a cascading field? In the target configuration, there will be a cascading field on Epic level and on Story level and the 1st field will have the same values, but not in the second field

Mo January 3, 2021

@andreas thank you so much!!!!

Sebastian Östlund April 19, 2021

And if I would like to copy more than 1 field?

Денис Шитягин October 14, 2021

Hi, can you please tell me what is wrong in my JSON?  I set up copying the value of the multi-level-cascading-select field, from one task to another, but the field with my JSON is not copied.

{
"update": {
"customfield_xxx": [
{
"set": {
"value": "{{triggerIssue.fields.customfield.customfield_xxx.value}}",
"child": {
"value": "{{triggerIssue.fields.customfield.customfield_xxx.child.value}}",
"child": {
"value": "{{triggerIssue.fields.customfield.customfield_xxx.child.value}}"
}
}
}
}
]
}
}

Like Stiven Espinosa likes this
Klára Zikešová September 27, 2022

thanks Andreas, you just saved me, works perfectly, made my day 

1 vote
Emrah Gültekin February 14, 2023

Hello guys

I want to copy 3 different select list (cascadeing) customfield from trigger issue to target issue.

How can you do this?

Help me please

Thanks

1 vote
Gustavo Segura January 2, 2020

hi @andreas thanks for the example!

I was trying to do something similar but if I execute this, it does not work.

{
"fields": {
"customfield_10043": "{{triggerIssue.customfield_10043.value}}",
"customfield_10043.child": "{{triggerIssue.customfield_10043.child.value}}"
}
}

It throws this error...

Error creating issueCan not instantiate value of type [simple type, class com.atlassian.jira.issue.fields.rest.json.beans.CustomFieldOptionJsonBean] from JSON String; no single-String constructor/factory method (customfield_10043)Unknown fields set during create, they may be unavailable for the project/type. Check your custom field configuration. Fields ignored - customfield_10043.child

However if use your code it works just fine, I was just trying to simplify it.

{
"update": {
"customfield_10043": [
{
"set": {
"value": "{{triggerIssue.fields.customfield_10043.value}}",
"child": {
"value": "{{triggerIssue.fields.customfield_10043.child.value}}"
}
}
}
]
}
}

Is there a reason why the first one won't work or am I missing something?

Pedro Chontal May 21, 2020

 

You are missing something, try this

{
 "fields": {
    "customfield_10043": {
        "value": "{{triggerIssue.fields.customfield_10043.value}}",
            "child": { "value" : "{{triggerIssue.fields.customfield_10043.child.value}}"
             } 
     }
 }
}

Like # people like this
Juan Francisco Sacristan Garcia March 2, 2022

The Gustavo Segura 2nd solution works for me too

0 votes
Nic Thiele August 30, 2023

I had to solve this problem differently on Jira Software/Server. I too was copying a Multi-Level Cascading Select from the trigger issue to a new task but was not successful using .child or .value. I could only get it to update the select by providing the IDs of the values in the additional fields section.

E.g.

{
"fields": {
"customfield_13421": [{ "id": 19280 }, { "id": 25321}, { "id": 25784} ]
}
}

When copying from the trigger issue, I had to use asJsonObjectArray("id").

 E.g.

{
"fields": {
"customfield_13421": {{triggerIssue.customfield_13421.asJsonObjectArray("id")}}
}
}

Additionally, if the trigger issue had a null value it failed and threw a JSON error. Checking for null proved difficult (isEmpty didn't work for me). I found this helpful:
https://community.atlassian.com/t5/Automation-questions/Automation-Rule-to-null-check-custom-field/qaq-p/1533044

E.g. my working solution:

{
"fields": {
"customfield_13421": {{#if(equals(triggerIssue.customfield_13421, null))}}null{{/}}{{triggerIssue.customfield_13421.asJsonObjectArray("id")}}
}
}
Volodymyr February 8, 2024

Waste some time finding the correct syntax, so would like to add how to populate the field with 3 levels based on values (not Ids):

{
"fields": {
"mlcs customfield_name or Id":[{ "value": "Level1"}, { "value": "Level 2"}, { "value": "Level 3"} ]
}
}

"Level 2" - is a value  from drop-down when you select "Level 1", "Level 3 " - is a 3d level value for "Level 2"

Like Nic Thiele likes this
0 votes
Vince Clark November 14, 2022

brilliant thanks 

0 votes
Raul Pelaez _TecnoFor - Marketplace Partner_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 19, 2022

Example with Automation Cloud to copy two cascade fields from parent to sub-tasks 

[code]

{
"fields": {
"customfield_10071": {"value":"{{triggerIssue.parent.customfield_10071.value}}", "child":{"value":  "{{triggerIssue.parent.customfield_10071.child.value}}"}},
"customfield_10069":  {"value":"{{triggerIssue.parent.customfield_10069.value}}", "child":{"value":  "{{triggerIssue.parent.customfield_10069.child.value}}"}}
}
}

[/code]

0 votes
Abin Jacob December 10, 2020

Hi @andreas 

Is it possible to inherit only the first value of a cascading field? In the target configuration, there will be a cascading field on Epic level and on Story level and the 1st field will have the same values, but not in the second field

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events