How to copy all versions from a multi-version picker custom field to Fix Versions?

We have a custom field called Milestone that is a "Version Picker (multiple versions)" field.  We want to set up an automation rule so that whenever the Milestone field is edited, the Fix Versions field is updated to match it.

Using the Edit Issue action, passing in {{issue.milestone.first.name}} works fine, as does {{issue.milestone.last.name}} -- but using {{issue.milestone.get(0).name}} (or any other value for get() ) does not.  Trying to pass in {{#issue.milestone}}{{name}}{{/issue.milestone}} does not work, so that's not an easy way to get all of the values copied over.

I've tried using the advanced Additional Fields section, but I've had no luck.

{
"fields": {
"fixVersions": [
{{#issue.milestone}}
{"name" : "{{name}}"} {{^last}}, {{/last}}
{{/issue.milestone}}
]
}
}

When I try to use the above, I get an error because the curly braces from the smart values make the JSON parser think the syntax is bad:

"Error parsing fields JSON: SyntaxError: Unexpected token { in JSON at position 38"

{
"fields": {
"fixVersions": [
{"name" : "{{#issue.milestone}}{{name}}{{^last}}" },
{"name" : "{{/last}}{{/issue.milestone}}" }
]
}
}

The uglier attempt above should also properly form the JSON we need to add every version from Milestone to Fix Versions, while itself being syntactically correct JSON.  However, while I'm able to save the action, but when I try to publish the rule, I get the following error:

"Error while parsing smart values."

 

I don't know what I'm doing wrong -- the smart values seem to parse correctly when I put that same text into the Description field.  Does anyone have any idea on how to fix this?  Or a better way to copy all versions from one field to another?

2 answers

1 accepted

This widget could not be displayed.

Hi Jeremy,

I just want to verify that if you're in server, that you've installed the latest version of Automation. We added the '.get' and '.getFromEnd' functions this week, so there's a good chance they're not working because you don't have them yet.

Unfortunately, the workaround you've chosen for now is the only way to copy a multi-select field into another one. Due to some complications with deep-copying of arrays/objects, you can't use syntax like:

{
"fields": {
"fixVersions": "{{issue.customfield_10034}}"
}
}

I've linked you into AUT-236 on our public issue tracker, where you can watch this issue. When it's resolved, we'll post an update to this thread to let you know it's been fixed (might be some time).

Let me know if you have any more questions!

Huw

Intern at Code Barrel

I have a similar problems but it could be caused from the specific multi-value custom field. Is the following approach correct to copy the whole list of parameters set in a parent issue?

{
"fields": {
"customfield_10501": "{{issue.customfield_10501}}"
}
}

Also, a "loop-over-something" feature could be a great improvement!

This widget could not be displayed.
Nick Menere Community Champion Jul 17, 2018

Just to update this issue - we know support copy values between different fields:

Screen Shot 2018-07-18 at 9.21.25 am.pngHope this is what you were after.

 

Cheers,

Nick

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Monday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

340 views 0 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you