Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I copy Multi-Level Cascading Select field from trigger issue instead of set values?

Kevin K January 3, 2022

Hi, 

I am struggling with copying Multi-Level Cascading Select fields to subtasks through automation. The documentation and questions I found online point to fields with parent + child options. However, the fields I am working with have 3 or 4 options (great-grandparent+ grandparent + parent + child). How could I modify the JSON below to copy customfield_12800 and customfield_13815 from the trigger issue? 

This is the JSON I have input in the advanced section of automation. I would like to change 12800 and 13815 to copy values from trigger issue:

{
"fields": {
"customfield_12800": [{
"value": "Bb"
}, {
"value": "All"
}, {
"value": "All"
}],
"customfield_14703": {
"value": "{{triggerIssue.fields.customfield_14703}}"
},
"customfield_13815": [{
"value": "Web"
}, {
"value": "Site"
}, {
"value": "Publish"
}, {
"value": "Standard"
}]
}
}

1 answer

0 votes
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2022

Hi @Kevin K

Could you provide an example of what the data from the trigger issue looks like and we might be able to figure out a smart value.

Cheers,

Simeon.

Kevin K January 4, 2022

Got it. So, these fields are copied from an original parent ticket to the trigger issue during automation. But are not carried down to tickets created by automation, so these 3 custom fields will need to be copied through this advanced section. I'd like to grab the values for 'Location'(customfield_12800) and 'Change Category'(customfield_13815) like I have with 'Location Region'(customfield_14703)

Here are snips of the custom fields on the ticket.chg cat.PNGloc.PNG

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 4, 2022

Hey @Kevin K,

So I'm not sure how you managed to get the multi select cascading select. I couldn't get one setup. But no matter, I'll show you how we get to the answer instead.

First of all, we need to see the rest representation of these fields so I can figure out how we get the values you want. For the above issues that you provided screenshots, can you access them via this URL format:

https://YOUR_JIRA_INSTANCE/rest/api/2/issue/ISSUE_KEY?expand=names 

And then show me the second for both of the fields that you want to copy from the trigger issue? They'll look vaguely like:

customfield_10128: {
self: "https://XXX/rest/api/2/customFieldOption/10437",
value: "Top Fred",
id: "10437",
child: {
self: "https://XXX/rest/api/2/customFieldOption/10439",
value: "Second Fred",
id: "10439"
}
}

You might want to filter your instance name out of the URLs too.

This field here that i'm showing you is a two level multi select. If i wanted to access the child value I'd use the follow smart value:

{{issue.customfield_10128.child.value}}

Hopefully that starts to make some sense, if you can get the above information we should be able to dig into what your smart value would be.

Cheers,

Simeon.

Kevin K January 5, 2022

Hi @Simmo ,

It looks like we use a plugin for the Multi-level cascading select custom fields. However, I've never used it to create. Hopefully this is what you are needing for the smart values of the fields:

"customfield_13815":[{"self":"https://x/rest/api/2/customFieldOption/15207","value":"Web","id":"15207","disabled":false},
{"self":"https://x/rest/api/2/customFieldOption/15717","value":"Sitecore","id":"15717","disabled":false},
{"self":"https://x/rest/api/2/customFieldOption/27120","value":"Publish Content - Broadband","id":"27120","disabled":false},
{"self":"https://x/rest/api/2/customFieldOption/27121","value":"Standard","id":"27121","disabled":false}]

"customfield_12800":[{"self":"https://x/rest/api/2/customFieldOption/12901","value":"Broadband","id":"12901","disabled":false},
{"self":"https://x/rest/api/2/customFieldOption/13342","value":"AAFES","id":"13342","disabled":false},
{"self":"https://x/rest/api/2/customFieldOption/22021","value":"All","id":"22021","disabled":false}]

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 5, 2022

Hey @Kevin K,

So, your customfield_13815 field looks like:

[
{
"self": "https://x/rest/api/2/customFieldOption/15207",
"value": "Web",
"id": "15207",
"disabled": false
},
{
"self": "https://x/rest/api/2/customFieldOption/15717",
"value": "Sitecore",
"id": "15717",
"disabled": false
},
{
"self": "https://x/rest/api/2/customFieldOption/27120",
"value": "Publish Content - Broadband",
"id": "27120",
"disabled": false
},
{
"self": "https://x/rest/api/2/customFieldOption/27121",
"value": "Standard",
"id": "27121",
"disabled": false
}
]

Which means that the values are just a flat array, so the operations that apply to them can be found at https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/.

Now are you wanting to copy the entire list from one field to another field of the same type?

If so, I think you can just do this:

{
"fields": {
"customfield_12800": {{triggerIssue.customfield_12800}}
}
}

Otherwise, now that I understand the format of your field, let me know if you're trying to copy bits of it or what you're trying for.

Cheers,

Simeon.

Kevin K January 5, 2022

Hi @Simmo ,

I am wanting to copy the entire list from one field to the same type field in a new ticket. However, I can't get it to work on those 2 fields. Only if I hard code values in there. 

I also tried the format used for customfield_14703, but no luck. So from below, 14703 will successfully copy, but 12800 will not since it has 3 values. 

{
"fields": {
"customfield_12800": {
"value": "{{triggerIssue.fields.customfield_12800}}"
},
"customfield_14703": {
"value": "{{triggerIssue.fields.customfield_14703}}"
},
"customfield_13815": [{
"value": "Web"
}, {
"value": "Sitecore"
}, {
"value": "Publish Content - Broadband"
}, {
"value": "Standard"
}]
}
}

Create issue

Error creating issue
Location is required. (customfield_12800)
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.
January 5, 2022

Hi @Kevin K 

Perhaps you could try using an iterator for that customfield_12800, treating it as a list, as described here for multiselect fields:

"customfield_12800" : [ {{#triggerIssue.fields.customfield_12800}} { "value": "{{value}}" } {{^last}}, {{/}}{{/}} ]

Kind regards,
Bill

Like # people like this
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 5, 2022

Hi @Kevin K,

did you try copying it in this format:

    "customfield_12800": {{triggerIssue.customfield_12800}}
 
Kevin K January 6, 2022

@Simmo @Bill Sheboy  Hi Guys, 

I'm not sure how to convert these to JSON format, but here's what I tried with Simmo's option. Still doesn't want to copy that field. 

{
"fields": {
"customfield_12800": {
"value": "{{triggerIssue.customfield_12800}}",
"customfield_14703": {
"value": "{{triggerIssue.fields.customfield_14703}}"
},
"customfield_13815": [{
"value": "Web"
}, {
"value": "Sitecore"
}, {
"value": "Publish Content - Broadband"
}, {
"value": "Standard"
}]
}
}
}

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2022

Hi @Kevin K,

I've taken your above example and formatted it to what I am trying to suggest:

{
"fields": {
"customfield_12800": {{triggerIssue.customfield_12800}},
"customfield_14703": {{triggerIssue.fields.customfield_14703}},
"customfield_13815": [
{
"value": "Web"
},
{
"value": "Sitecore"
},
{
"value": "Publish Content - Broadband"
},
{
"value": "Standard"
}
]
}

Note that because we're using smart values here the above now won't pass a JSON validator but it is what you want. The reason for that is that the smart value:

{{triggerIssue.customfield_12800}}

should output the reason of the JSON of the field and hopefully get us into a good place. Please give that a go and let us know how it turns out.

Cheers,

Simeon.

Kevin K January 6, 2022

@Simmo Tried the above format, but Automation doesn't want it to pass. I tried it on this first create issue from the logs: 

chg logs.PNG

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2022

Hey @Kevin K,

No worries, so then where ever you have that create action, add a log action after it. Copy and paste the exact same JSON into the log action and then we can see what it is outputting. If you can paste that into a message inside a code block we might be able to figure out what it is doing.

Cheers,

Simeon. 

Kevin K January 6, 2022

@Simmo It looks like it's grabbing the correct values, but failing on the parse? Is this what you are looking for? I filtered out the instance name. 

{ "fields": { "customfield_12800": {self=https:/x.com/rest/api/2/customFieldOption/12901, value=Broadband, id=12901, disabled=false}, {self=https://x/rest/api/2/customFieldOption/13342, value=AAFES, id=13342, disabled=false}, {self=https://x/rest/api/2/customFieldOption/22021, value=All, id=22021, disabled=false}, "customfield_14703": Central, "customfield_13815": [ { "value": "Web" }, { "value": "Sitecore" }, { "value": "Publish Content - Broadband" }, { "value": "Standard" } ] } }

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2022

Hey @Kevin K,

Damn, it looks like it might be doing something weird with that custom field. Any chance that you can raise a support ticket for this? It would make it a lot easier.

Cheers,

Simeon. 

Like Bill Sheboy likes this
Kevin K January 6, 2022

Yeah, no worries. It might be because of the plugin as well. I appreciate the help in trying to debug this! 

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events