Verify Assignee's Group in JMWE Validator

Olive Sun May 26, 2021

Hi There, 

 

I know there's a way to verify the user's group in JMWE via the following expression:

user.groups.includes("group name")

However, I met the scenario that needs to verify the assignee's group. Any advice on the expression?

 

Thanks,

Olive

 

1 answer

1 accepted

2 votes
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.
May 26, 2021

Hi @Olive Sun ,

you can do this:

issue.assignee && issue.assignee.groups.includes("group name")

It's important to first test whether issue.assignee is null, otherwise you'll get an error accessing its groups when it is.

Olive Sun May 26, 2021

Thanks, @David Fischer !That works perfectly.

Like John Funk likes this
Olive Sun May 27, 2021

Hi @David Fischer, would you mind also share the way to verify whether the assignee is in the specific project role or not?

Not sure if the following expression is correct.

 

issue.assignee && issue.assignee.getProjectRoles(issue.project).some(pr => pr.name == "Developers")

 

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.
May 27, 2021

@Olive Sun it is (assuming you're looking for the Developers project role)

Like Olive Sun likes this
Olive Sun July 4, 2021

Hi @David Fischer , I tried that expression, it only works when I set with "==":

issue.assignee && issue.assignee.getProjectRoles(issue.project).some(pr => pr.name == "Developers")

If I set with "!=" as follows, it doesn't work and keeps return "True".

issue.assignee && issue.assignee.getProjectRoles(issue.project).some(pr => pr.name != "Developers")

 Any thoughts?

 

Thanks,

Olive

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 5, 2021

Hi @Olive Sun 

why would you use != ? You mean for a different requirement? What would be the requirement then?

David

Olive Sun August 2, 2021

Hi @David Fischer , for one transition, I want to make the condition as the user is in project Role A, and for the other transition, I want to make the condition opposite wat. This means the user is not in project Role A. 

 

That's why I want to use !=, any thoughts?

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.
August 3, 2021

Hi @Olive Sun ,

that would be:

issue.assignee && !issue.assignee.getProjectRoles(issue.project).some(pr => pr.name == "Developers")
Olive Sun August 3, 2021

Thank yoooooou!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events