Skip to content

B24HelperManager Class

A versatile class that manages initial application data in Bitrix24. It provides methods for loading data, managing profiles, applications, payments, licenses, currencies, and options, as well as working with the Pull client.

TIP

You can test working with B24HelperManager in this example.

Initialization should be done through the hook useB24Helper.initB24Helper.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
async function init(): Promise<void>
{
	// ... ////
	$b24 = await initializeB24Frame()
	await initB24Helper(
		$b24,
		[
			LoadDataType.Profile,
			LoadDataType.App,
			LoadDataType.Currency,
			LoadDataType.AppOptions,
			LoadDataType.UserOptions,
		]
	)
	// ... ////
}
// ... ////

Methods

getLogger

ts
getLogger(): LoggerBrowser

Returns the current logger.

setLogger

ts
setLogger(
	logger: LoggerBrowser
): void

Sets the logger.

destroy

ts
destroy(): void

Destroys the Pull client.

loadData

ts
async loadData(
	dataTypes: LoadDataType[] = [
		LoadDataType.App,
		LoadDataType.Profile
	]
): Promise<void>

Loads data for the specified types.

See initB24Helper

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const {	initB24Helper, getB24Helper } = useB24Helper()
// ... ////
async function init(): Promise<void>
{
	// ... ////
	$b24 = await initializeB24Frame()
	await initB24Helper(
		$b24,
		[
			LoadDataType.Profile,
			LoadDataType.App,
			LoadDataType.AppOptions
		]
	)
	// ... ////
}
// ... ////

async function reloadData(): Promise<void>
{
	// ... ////
	return getB24Helper().loadData([
		LoadDataType.Profile,
		LoadDataType.App,
		LoadDataType.AppOptions
	])
	.then(() => {
		// ... ////
	})
}

usePullClient

ts
usePullClient(
	prefix: string = 'prefix',
	userId?: number
): B24HelperManager

Initializes the use of the Pull client.

Learn more

subscribePullClient

ts
subscribePullClient(
	callback: (message: TypePullMessage) => void,
	moduleId: string = 'application'
): B24HelperManager

Subscribes to events from the Pull client.

Learn more

startPullClient

ts
startPullClient(): void

Starts the Pull client.

Learn more

getModuleIdPullClient

ts
getModuleIdPullClient(): string

Returns the moduleId from subscribePullClient.

Should be used when sending a message to Pull.

Getters

isInit

ts
get isInit(): boolean

Returns true if the data is initialized.

ts
import { useB24Helper } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24)
// ... ////
$logger.info(getB24Helper().isInit)
// ... ////

profileInfo

ts
get profileInfo(): ProfileManager

Returns profile data.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.Profile])
// ... ////
$logger.info(getB24Helper().profileInfo.data)
// ... ////

appInfo

ts
get appInfo(): AppManager

Returns application status data.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().appInfo.data)
// ... ////

paymentInfo

ts
get paymentInfo(): PaymentManager

Returns application payment data.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().paymentInfo.data)
// ... ////

licenseInfo

ts
get licenseInfo(): LicenseManager

Returns Bitrix24 license data.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().licenseInfo.data)
// ... ////

currency

ts
get currency(): CurrencyManager

Returns currency data.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.Currency])
// ... ////
$logger.info({
	baseCurrency: getB24Helper().currency.baseCurrency,
	currencyList: getB24Helper().currency.currencyList
})
// ... ////

appOptions

ts
get appOptions(): OptionsManager

Returns application options.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.AppOptions])
// ... ////
$logger.info(getB24Helper().appOptions.data)
// ... ////

userOptions

ts
get userOptions(): OptionsManager

Returns user options.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.UserOptions])
// ... ////
$logger.info(getB24Helper().userOptions.data)
// ... ////

forB24Form

ts
get forB24Form(): TypeB24Form

Returns data for submission to a Bitrix24 feedback form (CRM form).

FieldTypeDescription
app_codestringApplication code in Bitrix24
app_statusstringApplication status
payment_expiredBoolStringString representation of a boolean value indicating whether the payment has expired ('Y' for expired, 'N' for active)
daysnumberNumber of days until payment expiration or after expiration
b24_planstringBitrix24 tariff plan identifier (relevant for cloud versions)
c_namestringUser's first name.
c_last_namestringUser's last name.
hostnamestringBitrix24 address (e.g., name.bitrix24.com).
ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App, LoadDataType.Profile])
// ... ////
$logger.info(getB24Helper().forB24Form)
// ... ////

TIP

You can test working with Bitrix24 feedback form (CRM form) in this example.

hostName

ts
get hostName(): string

Returns the Bitrix24 address.

ts
import { useB24Helper } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24)
// ... ////
$logger.info(getB24Helper().hostName)
// ... ////

isSelfHosted

ts
get isSelfHosted(): boolean

Returns true if the application is deployed on a self-hosted server.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().isSelfHosted)
// ... ////

primaryKeyIncrementValue

ts
get primaryKeyIncrementValue(): number

Returns the increment step for ID-type fields.

For self-hosted, it's 1; for cloud, it's 2.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().primaryKeyIncrementValue)
// ... ////

b24SpecificUrl

ts
get b24SpecificUrl(): Record<keyof typeof TypeSpecificUrl, string>

export const TypeSpecificUrl = {
	MainSettings: 'MainSettings',
	UfList: 'UfList',
	UfPage: 'UfPage'
} as const

Returns specific URLs for Bitrix24.

ts
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()

// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().b24SpecificUrl.MainSettings)
// ... ////

Released under the MIT License.