Good Day together,
I'm facing a bit of a challenge with Jira Automation and I'm hoping someone can guide me in the right direction. Here's my desired result in a Jira Automation Set Block:
{
"fields": {
"customfield_12029": [{"value": "Freiburg"}, {"value": "Wiesbaden"}]
}
}
However, the issue I'm encountering is that I only have the values "Freiburg" and "Wiesbaden" within the issue description as "Freiburg,Wiesbaden". I'm unsure about how to achieve the desired outcome using automation.
The complexity arises from the fact that the number of locations is dynamic, and it seems like I might need some sort of "for loop" to create the objects for the array.
While handling a single value is manageable, dealing with two values in a single string has proven to be quite challenging.
Splitting the string seems like an option, but due to the variable count of values, I can't implement this approach effectively. Additionally, setting 10 values, to cover ten possible values of which n could be null values, is not feasible because the function fails when attempting to set null values in a multi-select field.
I'd greatly appreciate any insights or ideas on how I could approach this problem and achieve the desired outcome using Jira Automation. Thanks in advance for your assistance!
I could use scriptrunner but my attempts to do so where not successful so far.
Best regards,
Björn Trier
So i found conditional smartValues, and this is kind of bad looking but operational for me :
Its just checking if the Value exists and if it does it inserts the object with the value in to the array, for a set amount of possible selections.
{
"fields": {
"customfield_14010": [
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(0)))}}
{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(0)}}"
}
{{/}}
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(1)))}}
,{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(1)}}"
}
{{/}}
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(2)))}}
,{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(2)}}"
}
{{/}}
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(3)))}}
,{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(3)}}"
}
{{/}}
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(4)))}}
,{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(4)}}"
}
{{/}}
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(5)))}}
,{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(5)}}"
}
{{/}}
{{#if(exists(issue.description.match("Zugang:(.*)").split(",").get(6)))}}
,{
"value": "{{issue.description.match("Zugang:(.*)").split(",").get(6)}}"
}
{{/}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello!
Found this post while trying to solve a similar issue. I needed to update a multiselect field with the results of a query I have on Metabase.
This was how I handled it.
PUT request body:
{
"fields": {
"customfield_10151": [
{{#webResponse.body.data.rows.get(0).get(1)}}{
"value": "{{.}}"
}{{^last}},
{{/}}{{/}}
]
}
}
Explanation:
{{#webResponse.body.data.rows.get(0).get(1)}} -> iterates my result list with all the values I want to replace on the custom field
{"value": "{{.}}"} -> the string outside of smartvalues syntax is used to make sure my json will be formatted as required by JIRA's API. {{.}} is used to get the current element value (that is being iterated by the smartvalues expression explained above).
{{^last}}, -> this makes sure that all items, except the last item iterated in my array, will be followed up by a comma character.
{{/}}{{/}} -> denotes the end of my iteration on the result set.
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.
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.