Select users included in two sets intersected with a third one

Select users included in two sets intersected with a third one

Problem

You want to perform complex operations on groups retrieved from Jira. For example, you want to select users included in two merged sets intersected with a third one. The sets can be either groups or roles.

Solution

The following solution is applicable to any other complex operation on sets of users.

The following script is from a real production system.

For the purpose of this solution, use the following SIL™ functions: usersInGroups, arrayToSet, arrayUnion, arrayGetElement, arrayIntersect.

//Which employees from branches placed in city1, city2 are working in sales and accountancy field? string [] branchcity1 = arrayToSet({"branchA", "branchB", "branchC"}); string [] branchcity2 = arrayToSet({"branchD", "branchE"}); string [] employeegroup = arrayToSet({"sales", "accountancy"}); string [] city1users; for(number i = 0; i < size(branchcity1); i = i + 1) { city1users = arrayUnion(city1users, usersInGroups(arrayGetElement(branchcity1, i))); } string [] city2users; for(number i = 0; i < size(branchcity2); i = i + 1) { city2users = arrayUnion(city2users, usersInGroups(arrayGetElement(branchcity2, i))); } string [] employees; for(number i = 0; i < size(employeegroup); i = i + 1) { employees = arrayUnion(employees, usersInGroups(arrayGetElement(employeegroup, i))); } string [] branchusers = arrayToSet(arrayUnion(city1users, city2users)); return arrayIntersect(employees, branchusers);

This script returns the list of users from branchcity1 and branchcity2 in the Accounting and Sales departments of a company.

Need support? Create a request with our support team.

Copyright © 2005 - 2025 Appfire | All rights reserved.