v1.1.0

Dialog Manager Class

Wraps the BX24 system dialogs (user picker, access permission picker, CRM entity picker) so they can be opened from inside a Bitrix24 application iframe.

DialogManager is exposed via $b24.dialog on a B24Frame instance and is only available when your application is rendered inside a Bitrix24 iframe (it relies on postMessage to talk to the parent window).

It mirrors the legacy BX24.selectUser, BX24.selectUsers, BX24.selectAccess and BX24.selectCRM helpers, but returns strongly-typed Promises instead of taking callbacks.

Methods

selectUser

async selectUser(): Promise<null|SelectedUser>

Displays the standard dialog for selecting a single company employee.

The promise resolves to a SelectedUser object, or null if the user closed the dialog without making a selection.

// ... /////
$b24 = await initializeB24Frame()
// ... /////
const makeSelectUser = async() => {
  const selectedUser = await $b24.dialog.selectUser()
  if (!selectedUser) {
    return
  }
  $logger.info(selectedUser)
}

selectUsers

async selectUsers(): Promise<SelectedUser[]>

Displays the standard dialog for selecting multiple company employees.

The promise resolves to an array of SelectedUser objects. The array is empty when the user confirms the dialog without picking anyone.

// ... /////
$b24 = await initializeB24Frame()
// ... /////
const makeSelectUsers = async() => {
  const selectedUsers = await $b24.dialog.selectUsers()

  const list = selectedUsers.map((row: SelectedUser): string => {
    return [`[id: ${row.id}]`, row.name].join(' ')
  })

  $logger.info(selectedUsers, list)
}

selectAccess

async selectAccess(blockedAccessPermissions?: string[]): Promise<SelectedAccess[]>

Displays the standard access permission selection dialog (departments, groups, individual users, and predefined permission codes such as AU or CR).

ParameterTypeDescription
blockedAccessPermissionsstring[]Optional list of permission codes to disable in the dialog. Defaults to []. Useful when some permissions are already granted elsewhere.

The promise resolves to an array of SelectedAccess entries.

// ... /////
$b24 = await initializeB24Frame()
// ... /////
const makeSelectAccess = async() => {
  const selected = await $b24.dialog.selectAccess(['AU'])

  $logger.info(
    selected.map(row => `${row.id}${row.name}`)
  )
}

selectCRM

async selectCRM(params?: SelectCRMParams): Promise<SelectedCRM>

Displays the standard dialog for selecting CRM entities (leads, contacts, companies, deals, quotes).

ParameterTypeDescription
params.entityTypeSelectCRMParamsEntityType[]Which entity types to show as tabs in the picker. Allowed values: lead, contact, company, deal, quote.
params.multiplebooleanAllow multiple selection. Defaults to false.
params.valueSelectCRMParamsValueOptional map of entity IDs to mark as initially selected. Applied only when multiple is true — single-select mode ignores it.

The promise resolves to a SelectedCRM object whose properties (lead, contact, company, deal, quote) are real JavaScript arrays of SelectedCRMEntity. Buckets for entity types the user did not pick (or did not request) are left undefined rather than set to an empty array.

Since v1.0.7, selectCRM always returns real arrays. Earlier versions forwarded the parent window's payload as-is, so each bucket was actually a Record<string, SelectedCRMEntity> (e.g. { 0: {...}, 1: {...} }) — calling .length or .map() on it returned undefined. Code written against the documented types continues to work; the only behavioural difference is that the runtime shape now matches the types.
// ... /////
$b24 = await initializeB24Frame()
// ... /////
const makeSelectCRM = async() => {
  const selected = await $b24.dialog.selectCRM({
    entityType: ['contact', 'company'],
    multiple: true,
    value: {
      contact: [42],
      company: [7]
    }
  })

  selected.contact?.forEach((row) => {
    $logger.info(`[${row.id}] ${row.title}${row.url}`)
  })

  selected.company?.forEach((row) => {
    $logger.info(`[${row.id}] ${row.title}`)
  })
}
Single-select mode (multiple: false) still resolves to the same SelectedCRM shape — buckets just contain at most one element. To grab that element use selected.contact?.[0].

Data Types

SelectedUser

Represents a single company employee picked through selectUser / selectUsers. The sub and sup flags describe the hierarchical relationship with the current user.

FieldTypeDescription
idNumberStringUser identifier — a string containing a numeric value (e.g. "42").
namestringFormatted display name.
photostringURL of the user's avatar.
positionstringUser's job title.
urlstringURL of the user's profile inside the portal.
subbooleantrue when the selected user is a subordinate of the current user.
supbooleantrue when the selected user is a supervisor of the current user.

SelectedAccess

Represents one entry returned by selectAccess.

FieldTypeDescription
idstringPermission code (see the table below).
namestringHuman-readable name of the permission, localized to the portal language.

The id field uses Bitrix24's permission-code grammar:

PatternMeaning
AUAll authorized portal users.
CRCurrent user.
U${number}A specific user by ID.
IU${number}An employee by ID (extranet-aware).
D${number}All employees of a department.
DR${number}All employees of a department, including subdepartments.
G${number}A user group (e.g. G2 — all visitors).
SG${number}A social network / workgroup.

SelectCRMParamsEntityType

type SelectCRMParamsEntityType = 'lead' | 'contact' | 'company' | 'deal' | 'quote'

The set of CRM entity kinds that selectCRM understands. Passed in as params.entityType and used as the keys of both SelectCRMParamsValue and SelectedCRM.

SelectCRMParamsValue

Map of entity IDs to pre-select when multiple: true. Only the requested entity types are read; extra keys are ignored.

FieldTypeDescription
leadnumber[]Lead IDs to mark as already selected.
contactnumber[]Contact IDs to mark as already selected.
companynumber[]Company IDs to mark as already selected.
dealnumber[]Deal IDs to mark as already selected.
quotenumber[]Quote IDs to mark as already selected.

SelectedCRMEntity

Represents one row inside a SelectedCRM bucket.

FieldTypeDescription
idstringPrefixed entity identifier — see the table in SelectedCRM.
typeSelectCRMParamsEntityTypeEntity kind (lead / contact / company / deal / quote).
placestringUI placement label used by Bitrix24 (rarely needed; informational).
titlestringDisplay title of the entity (e.g. company name, deal title, contact full name).
descstringShort description shown next to the title in the picker.
urlstringURL to open the entity inside the portal.

SelectedCRM

Result of selectCRM. Each property is either an array of SelectedCRMEntity refined with a literal id pattern, or undefined when the user picked nothing of that type.

FieldTypeDescription
lead(SelectedCRMEntity & { id: ``L_${number}`` })[]Picked leads. Each id looks like L_42.
contact(SelectedCRMEntity & { id: ``C_${number}``, image: string })[]Picked contacts. The extra image field holds the contact's avatar URL.
company(SelectedCRMEntity & { id: ``CO_${number}``, image: string })[]Picked companies. The extra image field holds the company logo URL.
deal(SelectedCRMEntity & { id: ``D_${number}`` })[]Picked deals. Each id looks like D_17.
quote(SelectedCRMEntity & { id: ``Q_${number}`` })[]Picked quotes. Each id looks like Q_3.