findUsersAndGroups method

Future<FoundUsersAndGroups> findUsersAndGroups({
  1. required String query,
  2. int? maxResults,
  3. bool? showAvatar,
  4. String? fieldId,
  5. List<String>? projectId,
  6. List<String>? issueTypeId,
  7. String? avatarSize,
  8. bool? caseInsensitive,
  9. bool? excludeConnectAddons,
})

Returns a list of users and groups matching a string. The string is used:

  • for users, to find a case-insensitive match with display name and e-mail address. Note that if a user has hidden their email address in their user profile, partial matches of the email address will not find the user. An exact match is required.
  • for groups, to find a case-sensitive match with group name.

For example, if the string tin is used, records with the display name Tina, email address sarah@tinplatetraining.com, and the group accounting would be returned.

Optionally, the search can be refined to:

  • the projects and issue types associated with a custom field, such as a user picker. The search can then be further refined to return only users and groups that have permission to view specific:

    • projects.
    • issue types.

    If multiple projects or issue types are specified, they must be a subset of those enabled for the custom field or no results are returned. For example, if a field is enabled for projects A, B, and C then the search could be limited to projects B and C. However, if the search is limited to projects B and D, nothing is returned.

  • not return Connect app users and groups.

  • return groups that have a case-insensitive match with the query.

The primary use case for this resource is to populate a picker field suggestion list with users or groups. To this end, the returned object includes an html field for each list. This field highlights the matched query term in the item name with the HTML strong tag. Also, each list is wrapped in a response object that contains a header for use in a picker, specifically Showing X of Y matching groups.

This operation can be accessed anonymously.

Permissions required: Browse users and groups global permission.

Implementation

Future<FoundUsersAndGroups> findUsersAndGroups(
    {required String query,
    int? maxResults,
    bool? showAvatar,
    String? fieldId,
    List<String>? projectId,
    List<String>? issueTypeId,
    String? avatarSize,
    bool? caseInsensitive,
    bool? excludeConnectAddons}) async {
  return FoundUsersAndGroups.fromJson(await _client.send(
    'get',
    'rest/api/3/groupuserpicker',
    queryParameters: {
      'query': query,
      if (maxResults != null) 'maxResults': '$maxResults',
      if (showAvatar != null) 'showAvatar': '$showAvatar',
      if (fieldId != null) 'fieldId': fieldId,
      if (projectId != null) 'projectId': projectId.map((e) => e).join(','),
      if (issueTypeId != null)
        'issueTypeId': issueTypeId.map((e) => e).join(','),
      if (avatarSize != null) 'avatarSize': avatarSize,
      if (caseInsensitive != null) 'caseInsensitive': '$caseInsensitive',
      if (excludeConnectAddons != null)
        'excludeConnectAddons': '$excludeConnectAddons',
    },
  ));
}