How to append a new release to the Fix Version without overwriting the existing releases values?
Asked by vincenzo_spatafora:

Dear Community,

I would like to create an automation rule in order to append a new release to the Fix Version field containing already other releases.

I have found this post:

[Update multiple fix version with automation for jira \| Automation \| Atlassian Support](https://support.atlassian.com/automation/kb/update-multiple-fix-version-with-automation-for-jira/)

and follow the given instructions.

Unfortuntaley, you get the following error against step 4 instruction:

(Version id '' is not valid (fixVersions))

Do you know as why?

Can somebody help me out?

Thanks, Vincenzo.


Answers:
author: Florian Bonniec
body: Hi [@vincenzo_spatafora](/t5/user/viewprofilepage/user-id/5485027)

The doc seems to be related to JIRA Cloud not JIRA DC.

Not sure what the trigger of the automation is but you can append FixVersion by using the edit issue action and FixVersion field with the following value.

![ac-fixVersion.png](https://community.atlassian.com/t5/image/serverpage/image-id/347960i257622E56DF7F98D/image-size/large?v=v2&px=999 "ac-fixVersion.png")

In this example if add V1 to the current list of versions.

Regards

comments: author: Ponnappan Ganapathiya
body: I believe it works in Jira DC too.


author: vincenzo_spatafora
body: Hi [@Florian Bonniec](/t5/user/viewprofilepage/user-id/495589),

thanks a lot.

I have tried that out as well and it works BUT:

if the Fix Version array field has got already more than 1 element (release value), the automation rule is overwriting all the existing Fix Version field values which I don't want.

Do you see a way out?

Thanks, Vincenzo.


author: Florian Bonniec
body: What is the trigger you are using and where does the version to happen come from ? Is it always the same ? Is it a version from another field ?


author: vincenzo_spatafora
body: Hi [@Florian Bonniec](/t5/user/viewprofilepage/user-id/495589)

first of all I confirm that the issues and releases belong to the same project whose Jira DC version is 9.12.12.

In my case, the trigger is Issue Linked and the condition Fix Version not empty.

If so, the rule is supposed to update the linked issue fix version field with the value of the destination issue; it does that but it also overwrites the exisiting fix version values, so I've come across the item I have posted in my question description.

I have followed your suggestion and as said it works but overwriting the existing values:

![Fix_Version.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/348171iE8F62D8A39308118/image-size/large?v=v2&px=999 "Fix_Version.PNG")

I understand there is a work aroud by using the Advanced Edit but I don't get right the JSON syntax or genuily there is a bug.

Thanks, Vincenzo.


author: Ponnappan Ganapathiya
body: ![EditIssue.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/348181i70402EE591F77C1A/image-size/large?v=v2&px=999 "EditIssue.PNG")

What happens if you try this?


author: Florian Bonniec
body: Have you try this configuration ?

![fixVersion.png](https://community.atlassian.com/t5/image/serverpage/image-id/348188i6F83DC5EF25E16AE/image-size/large?v=v2&px=999 "fixVersion.png")

Select FixVersion then ... \> Copy From and the config above.

Check add to existing values

Regards


author: vincenzo_spatafora
body: Hi [@Ponnappan Ganapathiya](/t5/user/viewprofilepage/user-id/5282370)

thanks: it does nothing, I understand because in this specific case the issue is the trigger issue.

Cheers, Vincenzo.


author: vincenzo_spatafora
body: Thank you [@Florian Bonniec](/t5/user/viewprofilepage/user-id/495589)

yeah, that's the way to do it; it works.

So true: sometimes you are in the woods and you don't see the tree.

Kind Regards, Vincenzo.


author: vincenzo_spatafora
body: [@Dick](/t5/user/viewprofilepage/user-id/4586768) [@Ponnappan Ganapathiya](/t5/user/viewprofilepage/user-id/5282370) [@Florian Bonniec](/t5/user/viewprofilepage/user-id/495589) [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

thank You very much for your help, very appreciated.

Grazie, Vincenzo.


author: Bill Sheboy
body: Hi [@vincenzo_spatafora](/t5/user/viewprofilepage/user-id/5485027)

The article you linked-to is for Jira Cloud and it describes *replacing by update*, not appending to the list of Fix Versions values.

For Jira Server / Data Center, please use the *name* attribute for Fix Version instead of the *id*.

And, use the "add" syntax with "update" to append to the list.

To see examples of this syntax, please look here: <https://confluence.atlassian.com/automation/advanced-field-editing-using-json-993924663.html>

Kind regards,  
Bill

comments: author: vincenzo_spatafora
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

nice to hear from you.

Do you mean like this:

{  
"update": {  
"fixVersions": \[  
{  
"add": {"name":"{{destinationIssue.fixVersions}}"}  
}  
\]  
}  
}

You get:

#### [Edit issue](https://pforge-spsfr.tls.fr.astrium.corp/jira/secure/AutomationProjectAdminAction!default.jspa?projectKey=GAL#/rule/176/23732) {#toc-hId-373611334}

Error while parsing additional fields. Not valid JSON.  
I don't understand as why it's not valid; the syntax seems correct to me.  
Thanks in advance, Vincenzo.


author: Bill Sheboy
body: There can be multiple values in the Fix Versions, and so they must be iterated over with an "add" for each one:

```
{
  "update": {
    "fixVersions": [
      {{#destinationIssue.fixVersions}}
        { "add": { "name": "{{name}}" } } {{^last}}, {{/}}
      {{/}}
    ]
  }
}
```


author: vincenzo_spatafora
body: Thank You [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , works indeed.

Very appreciated, thank a lot and I have tried that out with "id" (instead of "name") and for your info, with Jira DC 9.12.12 it's working too.

Have a nice evening, Vincenzo.


author: Dick
body: Hi [@vincenzo_spatafora](/t5/user/viewprofilepage/user-id/5485027)

the smart value in the example might be missing the closure tag:

`{`  
`"fields": {`  
` "fixVersions": [`  
` {{#issue.fixVersions}}{"id": "{{id}}"},{{/}}{"id": "{{version}}"} `  
**{{/}}**  
` ]`  
` }`  
`}`

comments: author: vincenzo_spatafora
body: Thanks Dick,

I have tried that out and you get now the following error message:

Error while parsing additional fields - Mismatched start/end tags: null != in template

Cheers, Vincenzo.


author: Dick
body: Hi Vincenzo,

on hindsight, I see the {{/}} in your equation. Then you proceed with a comma, followed by your own version smart value {{version}}.

You can let the automation log the  
`{{#issue.fixVersions}}{"id": "{{id}}"},`**{{/}}**`"id": "{{version}}"`  
**part of the json.**  
`You want to see that you're extending` the existing values separated by comma's with the new value.  
First check the string you're receiving, then put it in the variable :)


author: Dick
body: There's a couple of curly braces that I left out intentionally. Try the above please.


author: Dick
body: Total should be:  
`{`  
`"fields": {`  
` "fixVersions": [`  
` {{#issue.fixVersions}}"id": "{{id}}",{{/}} "id": "{{version}}" `  
` ]`  
` }`  
`}`


author: Dick
body: Within the square brackets is the array of strings.

In JSON format that would be something like \["string A", "String B", "String C"\]

that's why I removed the curly braces around your array elements.

[JSON format referral](https://www.w3schools.com/JS/js_json_arrays.asp)


author: vincenzo_spatafora
body: Thanks Dick.

You get now:

Error while parsing additional fields. Not valid JSON.

I use Jira Data Center version 9.12.12.

Kind Regards,

Vincenzo.


author: Dick
body: Okay, then it's not a complete string array, but an array of objects needing the single curly braces to encompass each element in the array...  
`{`  
`"fields": {`  
` "fixVersions": [`  
` {{#issue.fixVersions}}{"id": "{{id}}"},{{/}}{"id": "{{version}}"} `  
` ]`  
` }`  
`}`  
Can you log the value of smart values  
`{{#issue.fixVersions}}{"id": "{{id}}"},{{/}}`  
`for me?`


author: vincenzo_spatafora
body: Thanks [@Dick](/t5/user/viewprofilepage/user-id/4586768) for your time.

So, the syntax from the post above is correct (in step 4).

Here the log:

![FixVersion_Array_values.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/347973iB2444B468382D70A/image-size/large?v=v2&px=999 "FixVersion_Array_values.PNG")


author: Dick
body: Vincenzo, what is the value of the smart value {{version}} from your automation?


author: vincenzo_spatafora
body: Hi [@Dick](/t5/user/viewprofilepage/user-id/4586768),

I get no value out of it from the log and no error from the log.

By the way, it seems we got to use "name" instead of "id".

Cheers, Vincenzo.


author: Ponnappan Ganapathiya
body: Hi Vincenzo,

Could you paste the exact json string you used for this rule?

comments: author: vincenzo_spatafora
body: Thanks [@Ponnappan Ganapathiya](/t5/user/viewprofilepage/user-id/5282370),

there you go:

{ "fields": { "fixVersions": \[ {{#issue.fixVersions}}{"id": "{{id}}"},{{/}}{"id": "{{version}}"} \] } }

Cheers, Vincenzo.


author: Ponnappan Ganapathiya
body: I create a replica of this its working good. I think the problem is not with this part.


author: Ponnappan Ganapathiya
body: Could you please confirm the version and the issues belonging? Maybe the condition missing or conflict with the project where the version is created.


author: vincenzo_spatafora
body: Hi [@Ponnappan Ganapathiya](/t5/user/viewprofilepage/user-id/5282370),

I confirm that either the issues and releases belong to the same project.

Are you using DC or Cloud?

Cheers, Vincenzo.


author: Ponnappan Ganapathiya
body: [@vincenzo_spatafora](/t5/user/viewprofilepage/user-id/5485027) I am using DC 9.12.7

Hope you have validated the manual operation too. Like create a version and add that to the issues matching the condition you provided in the automation.

Regards,

Ponnappan.


Tags: data-center

jira-data-center

jira-software