How to copy Assets fields when closing issues by using Automation for Jira
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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.
Environment
Jira Software 8 or 9 with Automation for Jira (either installed separately or bundled).
Jira Service Management 4 or 5 with Automation for Jira installed.
The Assets field must be of the "Assets object" type, not the others available with Assets:
(see additional sections on the Solution for examples on how to achieve this for legacy fields)
Solution
On the Clone action, expand the "More options" section and add this JSON to the code block:
{
"fields": {
"customfield_10400": {{issue.customfield_10400.asJsonObjectArray("key")}}
}
}
Replace "customfield_10400" by the respective Assets field identifier in your instance.
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:
{
"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.