v1.2.0

Placement Manager Class

Used for managing the placement of widgets in the Bitrix24 application.
We are still updating this page. Some data may be missing here — we will complete it shortly.

Learn more

Getters

title

get title(): string

Alias of placement. Returns the placement title ('DEFAULT' when no title was provided by the parent window).

placement

get placement(): string

Returns the placement title. By default, returns 'DEFAULT' if the title is not set.

isDefault

get isDefault(): boolean

Returns true if the placement title is 'DEFAULT'.

options

get options(): any

Returns the placement options object. The object is frozen to prevent modifications.

isSliderMode

get isSliderMode(): boolean

Returns true if the widget is operating in slider mode (option IFRAME is 'Y').

// ... /////
$b24 = await initializeB24Frame()
// ... /////
if ($b24.placement.isSliderMode) {
    $b24.parent.setTitle('SliderMode')
}

Methods

getInterface

async getInterface(): Promise<any>

Getting information about the JS interface of the current embedding location: a list of possible commands and events.

// ... /////
$b24 = await initializeB24Frame()
// ... /////
const value: any = await $b24.placement.getInterface()

bindEvent

async bindEvent(eventName: string): Promise<any>

Setting up the event handler for the interface

call

async call(command: 'setValue', parameters: { value: string }): Promise<any>
async call(command: string, parameters?: Record<string, any>): Promise<any>

Call the registered interface command.

import { LoggerFactory } from '@bitrix24/b24jssdk'
// ... /////
const logger = LoggerFactory.createForBrowser('Demo', true)

$b24 = await initializeB24Frame()
// ... /////
$b24.placement.call('reloadData')
  .then((respose: any) => {
    logger.info('reload call')
  })
The setValue command is special: the parent window calls JSON.parse(value) on the received payload, so valuemust be a JSON-serialized string. Passing a raw string or an object directly will fail (SyntaxError from JSON.parse, or silent corruption to "[object Object]").Prefer the setValue helper, which serializes for you. If you use call('setValue', ...) directly, the SDK will throw a TypeError when value is not a string.
// ✗ throws TypeError — value is not a string
await $b24.placement.call('setValue', { value: 'test' })

// ✓ works — value is a JSON string
await $b24.placement.call('setValue', { value: JSON.stringify('test') })
await $b24.placement.call('setValue', { value: JSON.stringify({ id: 1 }) })

setValue

async setValue(value: unknown): Promise<any>

Convenience wrapper around placement.call('setValue', ...) that performs JSON.stringify on the value for you. Accepts any JSON-serializable value (string, number, boolean, object, array).

$b24 = await initializeB24Frame()
// ... /////
await $b24.placement.setValue('test')
await $b24.placement.setValue({ id: 1, title: 'demo' })

callCustomBind

async callCustomBind(
  command: string,
  parameters: null | string | Record<string, any>,
  callBack: (...args: any[]) => void
): Promise<any>

Calls an interface command and registers a callback that receives subsequent events from the command. Use this for commands that emit ongoing events (e.g. progress updates) instead of resolving once.

parameters accepts three shapes:

  • null — no payload.
  • string — sent as singleOption.
  • Record<string, any> — spread into the message payload.
$b24 = await initializeB24Frame()
// ... /////
$b24.placement.callCustomBind('subscribe', { topic: 'crm:deal' }, (event) => {
  console.log('event', event)
})