I'm trying to validate a custom filed that is a user multi-picker. I want to send an email to the people specified in that field but there is always a chance that a user will put there a person that is not meant to see that email.
So what I want to do is to check if users picked in that custom filed are members of one specific group.
Maybe I'm not searching carefully enough but I cannot find any solution.
So far i have managed to do this (not much considering this is a tutorial part mostly):
!!issue.customfield_15206 && issue.customfield_15206.some(it => it.groups == "team_name")
What I've learned is tht the second part is always false as te "it" object has no attribute groups.
Is there any way to achieve that? Or should I change the approach? Jira Automation maybe?
Hi @Jeremiasz Stróżyk ,
first of all, Jira Automation won't help you, since it doesn't integrate with workflows and thus doesn't offer any support for workflow validation.
However, there is a workaround: you can create a "real" user object from an accountId.
Also, your code seems to be checking that at least one user is selected in the custom field, and that at least one user in the field is in the team_name group. I think that's not your goal - you want to check that all users selected in the custom field are in the group, right?
Therefore, this Jira expression should work:
!issue.customfield_15206 || issue.customfield_15206.every(it => (new User(it.accountId)).groups.includes("team_name"))
Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events