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
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}}
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tom Hudgins Did you ever figure this out? I'm interested in a solution if you wouldn't mind sharing some of the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Change the code to exit after the first False. If there isn't any False then the code will return True.
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.