Resolves and manages sales and dealer teams: which organisation is the "team" for a given profile, which teams exist for the configured team organisation type, and who belongs to them. Reached from server-side JS as the teamManager service, and used throughout the leadman, team-lib and sales-data apps to scope leads, metrics and search results to a user's team. The active team organisation type and which groups count as team groups are configured on TeamApp.

Group: Managers


Properties

PropertyReturnsDescription
selectedGroupsList<Group>The groups configured on the team app as counting as team groups for the current tenant. When set, team member lookups are further restricted to profiles with a membership in one of these groups.
teamOrganisationOrganisationResolves the selected team organisation for the currently logged-in user. Prefers the user's team-selection cookie if one is set, then falls back to the same logic as teamOrganisation: User Administrator membership, then membership in the configured team organisation type, then the first primary non-root membership, then Administrator membership. Returns null if there is no current user or no team can be found.
teamTypeOrgTypeThe organisation type used to identify teams, as configured on the team app for the current tenant. Falls back to the default team org type if none has been explicitly selected.

Methods

searchUsers(String q, List<Organisation> teams, Group role, List<Group> selectedGroups) · teamOrganisation(Profile p) · getTeamOrganisation() · getTeamType() · getSelectedGroups() · allTeams() · allTeams(OrgType teamType) · teamMembers(Profile curUser, OrgType teamOrgType) · allTeamMembers(OrgType teamOrgType) · allTeamMembers(OrgType teamOrgType, List<Group> teamGroups) · teamsForUser(Profile curUser, OrgType teamOrgType) · changeGroupState(String groupName, boolean selected) · setSelectedOrgTypeName(String orgTypeName)

searchUsers(String q, List<Organisation> teams, Group role, List<Group> selectedGroups)

Returns: List<KSearchHit>

Searches the profile search index for users matching a free-text query, optionally restricted to a set of team organisations and to a specific role or set of groups. Matches on first name, surname, nickname, username, email and phone using a prefix match on each search term. This is an expensive lookup that queries Elasticsearch.

ParameterDescription
qfree-text search query, tokenised and matched as a prefix against name, username, email and phone fields; may be blank to skip text filtering
teamsorganisations to restrict the search to, or null/empty to search across all teams
roleif given, only profiles with a membership in this group are returned; takes precedence over selectedGroups
selectedGroupsif role is null, restricts results to profiles with a membership in any of these groups

teamOrganisation(Profile p)

Returns: Organisation

Finds the best team organisation for the given profile. If the profile is the current user this delegates to getTeamOrganisation so the user's cookie-based team selection is honoured; otherwise it falls back, in order, to the user's User Administrator membership, then their membership in the configured team organisation type, then their first primary non-root membership, and finally their Administrator membership. Returns null if the profile is null or no team can be found.

ParameterDescription
pthe profile to find a team organisation for

getTeamOrganisation()

Returns: Organisation

Resolves the selected team organisation for the currently logged-in user. Prefers the user's team-selection cookie if one is set, then falls back to the same logic as teamOrganisation: User Administrator membership, then membership in the configured team organisation type, then the first primary non-root membership, then Administrator membership. Returns null if there is no current user or no team can be found.

getTeamType()

Returns: OrgType

The organisation type used to identify teams, as configured on the team app for the current tenant. Falls back to the default team org type if none has been explicitly selected.

getSelectedGroups()

Returns: List<Group>

The groups configured on the team app as counting as team groups for the current tenant. When set, team member lookups are further restricted to profiles with a membership in one of these groups.

allTeams()

Returns: List<Organisation>

Finds all teams using the team organisation type configured for the current tenant. This is an expensive lookup that queries the organisation search index.

allTeams(OrgType teamType)

Returns: List<Organisation>

Finds all organisations of the given team organisation type. This is an expensive lookup that queries the organisation search index for every org of that type, up to 10000 results.

ParameterDescription
teamTypethe organisation type identifying teams; if null an empty list is returned

teamMembers(Profile curUser, OrgType teamOrgType)

Returns: List<Profile>

Finds all profiles who are members of any team that the given user belongs to, for the given team organisation type. This is an expensive lookup: it resolves the user's teams then loads the full member list of each one.

ParameterDescription
curUserthe profile whose teams are used to find fellow team members
teamOrgTypethe organisation type identifying teams

allTeamMembers(OrgType teamOrgType)

Returns: List<Profile>

Finds every profile that is a member of any team of the given team organisation type, across all teams, with no further group restriction. This is an expensive lookup capped at 100 results.

ParameterDescription
teamOrgTypethe organisation type identifying teams

allTeamMembers(OrgType teamOrgType, List<Group> teamGroups)

Returns: List<Profile>

Finds every profile that is a member of any team of the given team organisation type, further restricted to profiles who also belong to one of the given groups. This is an expensive lookup capped at 100 results.

ParameterDescription
teamOrgTypethe organisation type identifying teams; if null no teams are found and an empty list is returned
teamGroupsif given, restricts results to profiles with a membership in one of these groups

teamsForUser(Profile curUser, OrgType teamOrgType)

Returns: List<Organisation>

Finds the distinct organisations of the given team organisation type that the given user is a member of.

ParameterDescription
curUserthe profile whose team memberships are looked up
teamOrgTypethe organisation type identifying teams; if null an empty list is returned

changeGroupState(String groupName, boolean selected)

Returns: void

Adds or removes the named group from the team app's configured set of team groups for the current tenant.

ParameterDescription
groupNamethe name of the group to add or remove from the configured team groups
selectedtrue to add the group to the configured team groups, false to remove it

setSelectedOrgTypeName(String orgTypeName)

Returns: void

Sets the organisation type used to identify teams for the current tenant, on the team app.

ParameterDescription
orgTypeNamethe name of the organisation type to use as the team org type
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.