I'm trying to copy values from a custom field and add them to the Labels field on the same issue. The custom field type is: Select List (multiple choices)
Trigger
Value changes for Custom Field (any changes)
Create variable
Variable name: customField
Smart value:
{{issue.customfield_12345.value.replace(" ", "_")}}
This replaces spaces with underscores because the custom field allows values with spaces but the Labels field doesn't.
Edit issue fields
More options:
{
"fields": {
"labels": [
{{#customField.split(", ")}}
{ "add": "{{.}}" }
{{^last}},
{{/}}
{{/}}
]
}
}
Based on these threads I was expecting this to split the value into comma separated strings, then loop adding each one to the labels field. However, the audit log returns the error:
Error editing issues ID-1234 (Specify an string at index 0 for labels (labels))
Any thoughts appreciated - many thanks!
Hi @Simon Jones
First thing, I recommend always prefixing variable / table names in rules to avoid any problems with smart value name confusion. For example, using varCustomField instead of customField for the variable name.
Next, when using the "add" with the labels field in JSON, please use the "update" rather than the "fields" syntax: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/
If that does not solve this...if you write that variable to the audit log and test your rule, what does it contain? Is it what you expected.
Finally, when you create that variable, I recommend not allowing the rule to implicitly select what the delimiter should be for the list of values. Instead, take control of it to ensure it works as expected. For example:
{{issue.customfield_12345.value.replace(" ", "_").join(", ")}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.