Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Parent issue field to Distinct values of multiselect

Michiel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 14, 2024

Hi,

I am trying to copy the values of a custom "Checkboxes" field to the parent issue. I have a field named "Type" with the possible values "Frontend", "Backend". When a Story has a subtask with "Frontend" the story itself should copy this value.

With copy this goes ok, except for removing values. For example:

Story 1 

 - Subtask 1: Backend

 - Subtask 2: Frontend

Story 1 should now have the value "Frontend" and "Backend" as Type. When changing the value of Subtask 2 from Frontend to Backend the value of Type for Story 1 should now be only "Frontend".

I've tried the following:

{{issue.subtasks.customfield_10110.distinct.asJsonObjectArray("id")}}
But i cannot seem to get this working. Due to the nature of the checkboxes you get an array of id's ( `{"id": [1122, 1123]}`) when selecting multiple items.
Best regards,
Michiel

1 answer

0 votes
Michiel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 15, 2024

I managed to do this, it seems a bit over engineered to me:

{
"fields": {
"customfield_10110": [{{#issue.subtasks.customfield_10110.id.join(",").replaceAll("[\\[\\] ]","").split(',').distinct}}{"id": "{{.}}"}{{^last}},{{/}}{{/}}]
}
}

What this does is the following:

  1. Get all subtask field ids and join them together with ",", we now have a string containing [1234], [1234, 1235]
  2. Replace all unwanted characters, brackets and spaces, we now have a string containing 1234,1234,1235
  3. Split this into a list and get the distinct values, we now have a list containing 1234,1235
  4. Loop through this list, encapsulate each entry such that it becomes a json object and append a comma if it is not the last entry => string containing {"id": "1234"}, {"id": "1235"}
  5. Put brackets around the string to make it an array of json objects

Surely this could be done more readable? 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events