Skip to main content

Organization hierarchy

The organization hierarchy represents the structure of companies and their relationships with customers and users in the system. This model enables multi-tenant architecture with hierarchical organization structure.

Organization is a logical hierarchical grouping of customers, while a customer is a representation of a business partner usually managed in external systems like ERP or CRM. Multiple users can work on behalf of a given customer, and one user can act on behalf of multiple customers by changing their context.

Organization Service

The OrganizationService provides methods to interact with organizations data.

getOrganizationList

Retrieves a paginated list of organizations.

getOrganizationList(
options: Organizations.Request.OrganizationsListQuery
): Observable<Organizations.Model.Organizations | undefined>

Parameters

ParameterTypeDescription
optionsOrganizationsListQueryQuery parameters for filtering and pagination

Returns

An Observable that emits a paginated list of organizations or undefined.

Usage Example

organizationService
.getOrganizationList({
page: 1,
limit: 10,
})
.subscribe((organizations) => {
console.log(`Found ${organizations.total} organizations`);
console.log(`Showing page ${organizations.page} of ${organizations.pages}`);
organizations.items.forEach((org) => console.log(org.name));
});

getOrganization

Retrieves a specific organization by ID.

getOrganization(
params: Organizations.Request.GetOrganizationParams
): Observable<Organizations.Model.Organization | undefined>

Parameters

ParameterTypeDescription
paramsGetOrganizationParamsParameters containing the organization ID

Returns

An Observable that emits the requested organization or undefined if not found.

Usage Example

organizationService
.getOrganization({
id: 'org-123',
})
.subscribe((organization) => {
if (organization) {
console.log(`Found organization: ${organization.name}`);
console.log(`Active: ${organization.isActive}`);
console.log(`Has ${organization.children.length} child organizations`);
console.log(`Has ${organization.customers.length} customers`);
} else {
console.log('Organization not found');
}
});

Data Model Structure

The organization hierarchy model is designed to support multi-tenant applications with complex business relationships:

  1. Organizations can have multiple child organizations, creating a hierarchical structure
  2. Organizations can be associated with multiple customers
  3. Users can be associated with multiple customers
  4. Users can have different roles for different customers

This structure allows for flexible access control and business relationship modeling, where:

  • A user can work on behalf of multiple customers
  • A user can have different permissions (roles) when working with different customers
  • Organizations can manage multiple customers in a hierarchical structure
  • Customers represent actual business partners that may be managed in external systems

The pagination utility allows for efficient retrieval of large collections of organizations, supporting standard pagination parameters like page number and items per page.

Types

Party

Base abstract class for business entities.

FieldTypeDescription
idstringUnique identifier
namestringDisplay name
addressAddressPhysical address (optional)

Organization

Represents a company or its subdivision with hierarchical structure.

FieldTypeDescription
isActivebooleanWhether the organization is active
childrenOrganization[]Child organizations in the hierarchy
customersCustomer[]Customers associated with this organization

Customer

Represents a business partner.

Inherits all fields from Party.

User

Core user entity for authentication and authorization.

FieldTypeDescription
idstringUnique identifier
emailstringEmail address (used for login)
firstNamestringFirst name (optional)
lastNamestringLast name (optional)
rolesUserCustomerRole[]User roles associated with customers
customersCustomer[]Customers associated with this user

UserCustomerRole

Defines a role that a user has for a specific customer.

FieldTypeDescription
rolestringRole name/identifier
customerCustomerAssociated customer (optional)

Organizations

Paginated list of organizations.

type Organizations = Pagination.Paginated<Organization>;