Hello Atlassian Community!
I need help with Automation.
Here's a scenario - user provides data in a comment in this format:
{
"customfield_XXXXX": ["value 1", "value 2", "value 3"],
"customfield_YYYYY": "value Y",
"customfield_ZZZZZ": "Number",
}
Automation uses {{comment.last.body.substringBetween("\"customfield_XXXXX\": [", "],").trim()}} to populate a variable with data and then adds that data to a custom field.
This works for single select field and a number field, but I struggle to add data to multi select field.
Do you have any suggestion on how it should be built in order to populate customfield_XXXXX with provided data?
Thanks!
I received help regarding my issue from Haripriya from Atlassian Team and the automation is working correctly now.
Having a comment formatted as below:
{
"customfield_XXXXX": ["value 1", "value 2", "value 3"],
"customfield_YYYYY": "value Y",
"customfield_ZZZZZ": "Number",
}
Variable = {{comment.last.body.substringBetween("\"customfield_XXXXX\": [", "],").trim().remove("\"")}}
creates correct format which can be used in JSON later on (log action: Variable is value 1, value 2, value 3)
Then correct JSON in advanced field editing should look like this:
{
"update": {
"customfield_11177": [
{{#Variable.split(",").trim()}}{"add": {"value":"{{.}}"}}{{^last}},{{/}}{{/}}
]
}
}
There were two main issues:
#issue.Variable.split(",") was changed to #Variable.split(",")
and .trim() was added to avoid white spaces.
This would require advanced field editing options in the edit work item action.
See this KB article; how-to-update-a-select-field-multiple-from-the-content-of-other-fields
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Marc -Devoteam- and @Evgenii, thank you for your answers!
I used suggestions from the article, scenario 4
And there are some issues.
I created two variables for tests:
Var1 is "Option 1, Option 2"
Var2 is Option 1, Option 2
When using "update" with both Var1 and Var2 I receive error: Additional fields contains invalid 'update'. You can use 'add', 'remove', 'set' or 'edit' for operations.
When is use "fields" instead of "update" the rule is executed successfully but field is being cleared (when values are present) or no options are added (when field is empty). I also double checked - both Option 1 and Option 2 are correct and available in my multiselect list.
Then I tried to use single line custom field instead of variables and I'm receiving Error while parsing additional fields. Not valid JSON. (in both "update" and "fields" configurations and both "Option 1, Option 2" and Option 1, Option 2 input).
Do you have any suggestions on where the problem could be?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please show your automation rule and in detail the parts of the rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like, you have some problem with array of values.
Try this array, will it update? Haven't tested it by myself, will have time later.
{ "fields": { "customfield_XXXXX": [ {"value": "Option 1"}, {"value": "Option 2"} ] } }
If it will work, we'll think how to split your values from string to separate values
UPD: No, not working. I'll debug it later
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc -Devoteam- @Evgenii Thank You both for your commitment!
So here's my rule (version which run successfully but wipes data from the field/doesn't set provided values):
{{varOne}} = {{comment.last.body.substringBetween("\"customfield_11177\": [", "],").trim().remove("\"")}}
{{varTwo}} = "{{varOne}}"
{{varThree}} = {{comment.last.body.substringBetween("\"customfield_11177\": [", "],").trim()}}
I tested all three variables to try out three different text formats
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As in the documentation , you need to set the action to "add", and not to not "fields"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Marc -Devoteam-
Using "add" instead of "fields" provides error: "No fields or field values to edit for work items (could be due to some field values not existing in a given project)"
I tried it with all the variables and also a text field. Customfield is present on edit screen of the issue and there are no rules in the workflow blocking automation execution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the result if you set the advanced edit to:
{
"update": {
"customfield_XXXXX": [
{{#issue.customfield_XXXXX.split(",")}}{"add": {"value":"{{.}}"}}{{^last}},{{/}}{{/}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Marc -Devoteam-
Using "update" provides error: "Additional fields contains invalid 'update'. You can use 'add', 'remove', 'set' or 'edit' for operations."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This seems the rule actor has no permissions to update the custom field.
Does the rule actor have the correct permissions on the project?
Is the custom field also still on the screen used for edit action?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Dominik Kaźmierski and @Marc -Devoteam-
Another possible cause of this symptom is when the JSON is invalid due to a racetrack timing problem. That is, the smart value expression is not parsed fast enough before the JSON is validated / used in the advanced edit.
The mitigation / way to test for this is:
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.
Welcome to the community!
You can achieve your goal using an advanced JSON action in Jira Automation. The key is to structure the JSON payload correctly to update a multi-select custom field based on values from another field.
Here’s a working example:
If you want to populate customfield_10123 (a multi-select field) with values from customfield_10321 (e.g., a text field containing comma-separated values), use this JSON format:
This uses smart values to split the string by commas, iterate over each value, and add it to the multi-select field. The {{^last}},{{/last}} ensures proper comma placement in the JSON array.
{
"update": {
"customfield_10123": [
{{#issue.customfield_10321.split(", ")}}{"add":{"value":"{{.}}"}}{{^last}},{{/last}}
]
}
}
Alternatively, if you're working with Fix Versions or similar system fields, you can use:
{
"update": {
"fixVersions": [
{ "add": { "name": "{{ExistingFixVersion}}" } }
]
}
}
For more guidance, refer to Atlassian’s knowledge base, that earlier shared @Marc -Devoteam-:
https://support.atlassian.com/automation/kb/how-to-update-a-select-field-multiple-from-the-content-of-other-fields/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.