filter assignee list in jira based on organization chart

I have an organization like this:

TeamA, TeamB, TeamC and TeamD each team has a leader and team member I want to filter assignees in one project based on this condition : Leaders can assign tasks to team members themselves and other leaders Also, Team members can assign tasks just to the leader or other members of the team

How can we filter assignee list users based on this structure?

I write a code in customer picker script runner and using user filter to filter results, it works for filter groups but cannot filter based on the query as the sample I mentioned B2B groupname

import com.atlassian.jira.avatar.Avatar; import com.atlassian.jira.bc.user.search.UserSearchParams; import com.atlassian.jira.bc.user.search.UserSearchService; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.user.ApplicationUser; import com.atlassian.jira.user.UserFilter; import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption; import java.sql.ResultSet; import java.sql.PreparedStatement; import groovy.sql.Sql; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.util.Properties; import com.atlassian.core.util.ClassLoaderUtils; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.event.type.EventDispatchOption //Query connection def driver = "org.postgresql.Driver"; def url = "jdbc:postgresql://ip:5432/namedb"; def username = "sample"; def password = "sample"; Class dbClass = ClassLoaderUtils.loadClass(driver, this.class); Driver driverInstance = (Driver) dbClass.newInstance(); DriverManager.registerDriver(driverInstance); Properties info = new Properties(); info.put("user", username); info.put("password", password); Connection connection = driverInstance.connect(url, info); def sql = new Sql(connection) def String m_assignee = ''; def String tgm_assignee = ''; //get username login def userinfousername = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getUsername() //define paramters for get user object def issueManager = ComponentAccessor.getIssueManager() def issueService = ComponentAccessor.getIssueService() //sql query def sqlstr = "select managername,generalid from mcigeneralname l where l.generalid in (select generalid from mcigeneralname where jiraaccount="+userinfousername+')' def userSearchService = ComponentAccessor.getComponent(UserSearchService) def userManager = ComponentAccessor.userManager def avatarService = ComponentAccessor.avatarService def authenticationContext = ComponentAccessor.jiraAuthenticationContext def groupManager = ComponentAccessor.groupManager def userFilter = new UserFilter(true, null, ['B2B', 'B2B']) def userSearchParams = new UserSearchParams.Builder().allowEmptyQuery(true).filter(userFilter).maxResults(30).build() search = { String inputValue -> userSearchService.findUsers(inputValue, userSearchParams) } /* * Retrieve the user from internal storage (we store the key). Return them if they still exist, regardless of * their group membership. */ getItemFromId = { String id -> userManager.getUserByKey(id) } /* * The user is still "valid" if they are a member of either of the below-mentioned groups, otherwise they become "disabled". */ validate = { ApplicationUser user -> groupManager.getGroupNamesForUser(user).intersect(['B2B', 'B2B']) } renderItemViewHtml = { ApplicationUser user -> user.displayName } renderItemTextOnlyValue = renderItemViewHtml toOption = { ApplicationUser user, Closure<String> highlight -> def remoteUser = authenticationContext.getLoggedInUser() new PickerOption( value: user.key, label: user.displayName, html: highlight(user.displayName, false), icon: avatarService.getAvatarURL(remoteUser, user, Avatar.Size.SMALL)?.toString() ) } 
2

Related questions 1 Inheritance Tree for Task Types in Gradle 37 how to create JIRA quick filter where assignee is Unassigned 8 assignee in jira workflow Related questions 1 Inheritance Tree for Task Types in Gradle 37 how to create JIRA quick filter where assignee is Unassigned 8 assignee in jira workflow 0 How to set assignee with Jira Script Runner? 0 Make cascading list mandatory on JIRA based on another cascading list 0 How to get a list of all the options for a CustomField in an issue (Jira)? 2 By default assignee=reporter in jira 1 search JIRA for issues where assignee = reporter Load 5 more related questions Show fewer related questions

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like