Hi dear Community,
I'm stumped that I can't get the solution of How-to-combine-values-from-various-multiple-select-fields to work in my usecase.
The setup:
The problem is quite similar to the question linked above. I have a top-level Movement issuetype that has children of the Initiative issuetype. On both the Movement and Initiative issuetypes I have the same custom field (customfield_10301, which I'll call "Domain" in the rest of this post) that is a multiselect list with five possible entries (call them A, B, C, D and E).
My Goal:
If the Domain entry of one of the Initiatives changes, I need to reflect that change in the value of the Domain entry that resides on the parent Movement Jira item.
Example:
Initiatives 1 and 2 are children of Movement X , and their customfield is filled like this:
Initiative 1 Domain: A, B, D, E
Initiative 2 Domain: A, C
Movement: Domain: A, B, C, D, E
If the Domain value of initiatieve 1 changes to A, B, D, Movement X to be filled with: A, B, C, D (which is a logical "or" executed on the values of the Domains of its children).
Step by Step:
0: The trigger of the automation would be a change in the Domain value of an Initiative
Followed immediately by the check if it's an Initiative that we're dealing with:
And checking if the Initiative indeed has a parent Movement
1: As per @Bill Sheboy's solution in the link above, I first lookup the issues:
And I verify the lookup by logging it (the correct issues are looked up) using
This indeed gives me the initiatives that are children of the parent Movement of the trigger Initiative (the square brackets are there to more easily see an empty result).
2: I then branch into the parent Movement by
and then apply the magic in Bill's solution by editing the Movement using the more options and then Json with the smart values on the looked-up Jira items:
{
"update": {
"customfield_10301": [
{{#lookupIssues.customField_10301.value.flatten.distinct}}
{
"add": { "value": "{{.}}" }
} {{^last}},{{/}}
{{/}}
]
}
}
3: As you might've guessed (if you've read so far), the magic didn't happen in my case.
I've been dabbling with creating variables inside the automation and writing their content to the audit log, to find out what is going on. It seems that as soon I'm using either flatten or distinct, I end up with an empty Domain value.
What am I missing here?
Kind regards,
Dick
Hi @Dick
I think the issue is with the structure returned by the multi-select field, not the lookup itself.
lookupissues gives you a list of work items, and each work item has its own list of Domain options. So effectively you have a list of lists. You need to flatten that collection first and then apply distinct.
I would first test this directly in the audit log:
{{lookupIssues.customfield_10301.value.flatten().distinct}}
With your example:
Initiative 1 --- A, B, D
Initiative 2 --- A, C
This should return
A, B, D, C
I found that funcitions here.
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists
One thing I would change in your JSON is that you're using the option values to build the update manually. For a multi-select field, I would first confirm exactly what Automation is returning before constructing the JSON.
Please set these 3 logs; they will tell us at what level the value becomes empty.
{{lookupIssues.customfield_10301}}
{{lookupIssues.customfield_10301.value}}{{lookupIssues.customfield_10301.value.flatten().distinct}}
Regards,
Gor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.