Hi,
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.
Now, the problem with your Jira expression is that User picker custom fields, unlike standard user fields such as Assignee, don't return User "objects" but just a generic JavaScript object that has no methods.
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"))
Regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.