JMWE Condition to check if users in a multi-user picker are in a certain group

Tom Hudgins
Contributor
July 10, 2024

Hello,

I'm trying to write a JMWE post-op transition script that will conditionally transition the issue only if ALL the users in a multi-user picker are in a certain group.

I have this:

{% for user in issue.fields.customfield_19486 %}
{{ user | isInGroup('training-complete') }}
{% endfor %}

and I get something like

true
false

but what I really want is just a true/false for the entire set of users overall.

I feel like I should be able to use a filter that looks something like this:

{{ issue.fields.customfield_19486 | filter({isInGroup('training-complete')}) }}

I know that's not the syntax for a filter but I can't quite figure out how to do this more succinctly. 

Thanks for any help

3 answers

1 accepted

1 vote
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 10, 2024

Hi @Tom Hudgins 

try this:

{% set allIn = true %}
{% for user in issue.fields.customfield_19486 %}
{% set allIn = allIn and (user | isInGroup('training-complete')) %}
{% endfor %}
{{allIn}}
Tom Hudgins
Contributor
July 11, 2024

Thanks David,

I had toyed with going down this route but it felt like there might have been some sort of one-liner that would do it. 

In the end, I have to add more logic for a few other tests so this is better anyway - and more readable as well.

Thanks very much!

0 votes
Russell Kent
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!
October 31, 2024

@Tom Hudgins Did you ever figure this out? I'm interested in a solution if you wouldn't mind sharing some of the code.

Tom Hudgins
Contributor
October 31, 2024

I used basically the same code as proposed by David. I ended up setting the original value to false and then OR'ing the "inGroup" response inside the loop but it's basically the same thing.

Like Russell Kent likes this
0 votes
Shawn Doyle - ReleaseTEAM
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 10, 2024

Change the code to exit after the first False.  If there isn't any False then the code will return True.

Suggest an answer

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

Atlassian Community Events