Forums

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

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

Jeremy Mejia
Contributor
January 3, 2018

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

2 accepted

1 vote
Answer accepted
Nick Menere
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.
July 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.png Hope this is what you were after.

 

Cheers,

Nick

0 votes
Answer accepted
Huw Evans
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 4, 2018

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

Alessandro Tondo
Contributor
February 9, 2018

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!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events