How to copy Assets fields when closing issues by using Automation for Jira

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

When cloning Issues in Automation for Jira, for example, Assets fields aren't automatically copied over to the newly created Issue.

This article suggests one way you can implement this Assets field copy.

Solution

On the Clone action, expand the "More options" section and add this JSON to the code block:

1 2 3 4 5 6 {"fields": { "customfield_10400": { {issue.customfield_10400.asJsonObjectArray("key")} } } }

Replace "customfield_10400" by the respective Assets field identifier in your instance.

Edit field in automation using Additional field

This will make Jira read the Assets field and parse it into a JSON Array already compatible with the create/update format — it works both for single and multi-select Assets object field.

The solution above was derived from the following articles:

For the Assets object (multiple) (legacy)

You can copy the legacy multiple field with this snippet instead:

1 {"fields": {"customfield_10400": [{{#issue.customfield_10400.substringBetween("(",")")}}{"key": "{{.}}"}{{^last}}, {{/}}{{/}}]}}

If your Assets object contain parenthesis on their names, this snippet will try to parse that into an object — if it doesn't exist it'll be ignored and the other values will be added.

Updated on May 31, 2024

Still need help?

The Atlassian Community is here for you.