Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

The availability of the users personal data may be impacted by the recent changes by Atlassian in order to meet GDPR compliance. See the following for more information:

  • This routine is available starting with katl-commons 1.0.
  • This routine is available for Jira server and cloud deployment options.
    Info
    titleAvailability
    Table plus
    applyColStyleToCelltrue
    heading0
    columnTypess,s,s,s
    multiplefalse
    columnAttributesstyle="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold,
    enableSortingfalse

    Syntax

    usersInGroups(groups[, activeUsersOnly])

    Package

    Alias

    Pkg Usage

    Description

    Excerpt
    hiddentrue

    Returns a list of users common to all the specified groups.

    Returns a list of users common to all the specified groups.

    Parameters

    Table plus
    applyColStyleToCelltrue
    columnTypess,s,s,s
    heading0
    multiplefalse
    enableSortingfalse

    Parameter name

    Type

    Required

    Description

    groups

    ...

    String []

    Yes

    Array containing the groups names to retrieve the common users from.

    Return type

    ...

    activeUsersOnly

    Boolean

    No

    If true only active users will be returned. If false both active an inactive users will be returned.

    Return Type

    String []

    Returns a list with the usernames of the common users for all the specified groups. The result of the routine is  is the intersection of the sets of users for each specified group, not the union.

    ...

    Examples

    Example 1

    Code Block
    //The following users belong to both groups jira-developers and jira-administrators: user1, user2
    string [] groups = {"jira-developers", "jira-administrators"};
    string [] usersByGroups;
    usersByGroups = usersInGroups(groups);
    print("The following users belong to both groups jira-administrators and jira-developers: ");
    print(usersByGroups);
    

    Result: The following users belong to both groups jira-administrators and jira-developers: user1|user2

    ...

    Code Block
    function getUsers(string [] groups){ 
      string [] users; 
      for(string group in groups){ 
        string [] currentGrp; 
        currentGrp = addElement(currentGrp, group); 
        for(string user in usersInGroups(currentGrp)){ 
          users = addElementIfNotExist(users, user); 
        } 
      } 
      return users;
    } 
    
    
    string [] groups = {"jira-developers", "jira-administrators"}; 
    description = getUsers(groups); 
    
    

    This example uses the usersInGroups routine to get all users in each group individually and then adding them into a predefined array. So the usersInGroups routine will be called twice: once for jira-administrators and once for jira-developers. Since each time it will be called with a single group, it will return all users from the specified group.Starting with katl-commons 2.5.7, the code above

    Example 3: Union of groups

    The code above (example 2) can be rewritten with the following code:

    Code Block
    string [] developers = usersInGroups({"jira -developers"});
    string [] administrators = usersInGroups ({"jira-administrators"});
    return arrayUnion (developers, administrators );

    See also

    Filter by label (Content by label)
    showLabelsfalse
    max

    ...

    25
    showSpacefalse
    cqllabel = "user_routine" and space = currentSpace ( )
    labels

    ...

    array_

    ...

    routines