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
.
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
getLogger(): LoggerBrowser
Returns the current logger.
setLogger
setLogger(
logger: LoggerBrowser
): void
Sets the logger.
destroy
destroy(): void
Destroys the Pull
client.
loadData
async loadData(
dataTypes: LoadDataType[] = [
LoadDataType.App,
LoadDataType.Profile
]
): Promise<void>
Loads data for the specified types.
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
usePullClient(
prefix: string = 'prefix',
userId?: number
): B24HelperManager
Initializes the use of the Pull
client.
subscribePullClient
subscribePullClient(
callback: (message: TypePullMessage) => void,
moduleId: string = 'application'
): B24HelperManager
Subscribes to events from the Pull
client.
startPullClient
startPullClient(): void
Starts the Pull
client.
getModuleIdPullClient
getModuleIdPullClient(): string
Returns the moduleId
from subscribePullClient
.
Should be used when sending a message to Pull
.
Getters
isInit
get isInit(): boolean
Returns true
if the data is initialized.
import { useB24Helper } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24)
// ... ////
$logger.info(getB24Helper().isInit)
// ... ////
profileInfo
get profileInfo(): ProfileManager
Returns profile data.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.Profile])
// ... ////
$logger.info(getB24Helper().profileInfo.data)
// ... ////
appInfo
get appInfo(): AppManager
Returns application status data.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().appInfo.data)
// ... ////
paymentInfo
get paymentInfo(): PaymentManager
Returns application payment data.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().paymentInfo.data)
// ... ////
licenseInfo
get licenseInfo(): LicenseManager
Returns Bitrix24 license data.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().licenseInfo.data)
// ... ////
currency
get currency(): CurrencyManager
Returns currency data.
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
get appOptions(): OptionsManager
Returns application options.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.AppOptions])
// ... ////
$logger.info(getB24Helper().appOptions.data)
// ... ////
userOptions
get userOptions(): OptionsManager
Returns user options.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.UserOptions])
// ... ////
$logger.info(getB24Helper().userOptions.data)
// ... ////
forB24Form
get forB24Form(): TypeB24Form
Returns data for submission to a Bitrix24 feedback form (CRM form).
Field | Type | Description |
---|---|---|
app_code | string | Application code in Bitrix24 |
app_status | string | Application status |
payment_expired | BoolString | String representation of a boolean value indicating whether the payment has expired ('Y' for expired, 'N' for active) |
days | number | Number of days until payment expiration or after expiration |
b24_plan | string | Bitrix24 tariff plan identifier (relevant for cloud versions) |
c_name | string | User's first name. |
c_last_name | string | User's last name. |
hostname | string | Bitrix24 address (e.g., name.bitrix24.com ). |
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
get hostName(): string
Returns the Bitrix24 address.
import { useB24Helper } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24)
// ... ////
$logger.info(getB24Helper().hostName)
// ... ////
isSelfHosted
get isSelfHosted(): boolean
Returns true
if the application is deployed on a self-hosted server.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().isSelfHosted)
// ... ////
primaryKeyIncrementValue
get primaryKeyIncrementValue(): number
Returns the increment step for ID-type fields.
For self-hosted, it's 1
; for cloud, it's 2
.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().primaryKeyIncrementValue)
// ... ////
b24SpecificUrl
get b24SpecificUrl(): Record<keyof typeof TypeSpecificUrl, string>
export const TypeSpecificUrl = {
MainSettings: 'MainSettings',
UfList: 'UfList',
UfPage: 'UfPage'
} as const
Returns specific URLs for Bitrix24.
import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'
const { initB24Helper, getB24Helper } = useB24Helper()
// ... ////
await initB24Helper($b24, [LoadDataType.App])
// ... ////
$logger.info(getB24Helper().b24SpecificUrl.MainSettings)
// ... ////