How to copy multi-select field value into Affects Versions field?
Asked by Kelvin Teng:

Hi,

Appreciate some advice from the community on how to copy multi-select custom field values into Affects Version field.

For example, I have a multi-select custom field called Software Version and have multiple options selected in the field. Like Version 1, Version 2, Version 3.

In the automation, I've configured it to copy the Software Version -\> Version 1, Version 2 and Version 3 into Affects Versions field when linked to another issue.

So far I have not been successful to make it to copy multiple values into Affects Versions field. But it works if it is copying a single value.

Thank you everyone in advanced.


Answers:
author: Marc - Devoteam
body: Hi [@Kelvin Teng](/t5/user/viewprofilepage/user-id/5469702)

If you update your rule, first in the log action, change the smart value to {{triggerIssue.customfield_12721.value}}

And add another log action and use {{triggerIssue.customfield_12721.name}}

See what both actions log.

then we can move forward.

comments: author: Kelvin Teng
body: Hi Marc,  

I've added log action for {{triggerIssue.customfield_12721.name}}, nothing is in the log

![Screenshot 2024-09-11 163133.png](https://community.atlassian.com/t5/image/serverpage/image-id/346769i01BC7FA98300E7ED/image-size/large?v=v2&px=999 "Screenshot 2024-09-11 163133.png")


author: Marc - Devoteam
body: Hi [@Kelvin Teng](/t5/user/viewprofilepage/user-id/5469702)

But on value option you have information, so this is what we need.

Now create a variable, based on smart value {triggerIssue.customfield_12721.value}}

Use this variable in your edit action in the branch


author: Dick
body: Hi Kelvin and Trudy,

The multi-select variable yields a list of consecutive values as an answer. In order to tell Jira it has to work with a list during the copying to the destination issue, you need to use {{#issue.multivariable}} similar to [Atlassian on smart values and lists](https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-lists/) So the edit process should definitively be an advanced edit, not a regular one.

comments: author: Kelvin Teng
body: Hi Dick,

I've tried using advanced edit with the following:
> {
>
> "versions": {{triggerIssue.customfield_12721.value}}  
>
> }

And it returns the error below:

No fields or field values to edit for issues (could be due to some field values not existing in a given project)

I've also tried putting quotations "{{triggerIssue.customfield_12721.value}}" doesn't seem to help


author: Dick
body: The essential part (the multi-value part) is in the hashtag # :

And triggerissue has no capitals (no camel casing).

The value parsed should imo be part inside the loop in object notation: {{value}}

And the "human readable" name of the customfield should be used.

And you should close the multi-value part with the slash: {{/}}

**{{#triggerissue.Affects Versions}}{{value}}{{/}}**


author: Dick
body: you can log the above line (make visible what it parses and see if it matches what should be the "value" copied.


author: Trudy Claspill
body: Hello [@Kelvin Teng](/t5/user/viewprofilepage/user-id/5469702)

Please show us screen images of your entire rule and the details of each step, so that we can advise you how to modify it.

Also please share the output in the rule execution log for the rule executing and trying to copy multiple values.

comments: author: Kelvin Teng
body: Hi Trudy,

Thank you for your assistance.

![Screenshot 2024-09-11 100927.png](https://community.atlassian.com/t5/image/serverpage/image-id/346715i5A3AE8C9CE2C3C64/image-size/large?v=v2&px=999 "Screenshot 2024-09-11 100927.png")![Screenshot 2024-09-11 100852.png](https://community.atlassian.com/t5/image/serverpage/image-id/346716i35BCA0BB37647B9C/image-size/large?v=v2&px=999 "Screenshot 2024-09-11 100852.png")


author: Trudy Claspill
body: What are the details of the Create Variable step?

What is the actual result? What is the value of the Affects Versions field when this rule executes?

A Variable is generally stored as a String. Attempting to copy a single string of comma separated values into a multiple selection field is not generally going to work. Instead you would have to do some parsing of the values and potentially some branching to get each value added as another value in the multi-select Affects Versions field.


author: Kelvin Teng
body: Hi Trudy,

Thank you for the quick response. The actual result is empty. There is no value populated in Affects Versions field. Below is the screenshot of the Create Variable step.

![Screenshot 2024-09-11 133131.png](https://community.atlassian.com/t5/image/serverpage/image-id/346732iFAC82A3F721CFC6B/image-size/large?v=v2&px=999 "Screenshot 2024-09-11 133131.png")
> Instead, you would have to do some parsing of the values and potentially some branching to get each value added as another value in the multi-select Affects Versions field.

May I know how I can do this?


author: Bill Sheboy
body: Hi [@Kelvin Teng](/t5/user/viewprofilepage/user-id/5469702)

Adding to Trudy's suggestions...

Do you want to *replace the values* in the destination issue's Affects Versions field or *add to the existing values*?

What is the type of your source, custom field: multiple-selection Version, multiple-section Option, something else?

If you want to *replace* the values and the source field is already *multiple-selection, version type*, the edit issue action could directly copy them, using the COPY option to the right of the field in the action.

For all other cases, your rule will need to use advanced edit with JSON to add the values by the name of the versions: <https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Affects-Versions>

That may be done by[iterating over the values](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#Combined-function-examples) in the source custom field to dynamically create the JSON for use.

Kind regards,  
Bill


Tags: cloud

jira-service-management

jira-service-management-cloud