Custom Smart Processes Development for Bitrix24
Smart Processes are CRM entities that you create, not the Bitrix developers. Not a lead and not a deal, but a "Contract", "Purchase Request", "Claim", "Project", "Tenant" — tailored to your business specifics. Technically these are dynamic CRM entities (\Bitrix\Crm\Service\Factory), stored in tables b_crm_dynamic_items_{entityTypeId}.
What Can Be Created Through the B24 Builder
In CRM settings → "Smart Processes", a manager creates a new type: adds user-defined fields, configures the stage pipeline, enables the required blocks (contact, company, products, documents). This works for simple cases.
Custom development is needed when:
- Smart process fields must be calculated automatically.
- Creating an element triggers a chain of actions (create a linked element, send a notification, register in 1C).
- A non-standard card with custom UI is required.
- Integration of the smart process with an external system is needed.
Creating a Smart Process via REST API
Creating the type programmatically — convenient for deployment between environments:
$result = $b24->callMethod('crm.type.add', [
'fields' => [
'title' => 'Claim',
'isUseInUserfieldEnabled' => true,
'isLinkWithProductsEnabled' => true,
'isStagesEnabled' => true,
'isRobotsEnabled' => true,
'isBizProcEnabled' => true,
],
]);
$entityTypeId = $result['result']['type']['entityTypeId']; // e.g. 1052
After receiving entityTypeId, add user-defined fields:
$b24->callMethod('crm.type.fields.add', [
'entityTypeId' => $entityTypeId,
'fields' => [
'fieldName' => 'CLAIM_NUMBER',
'userTypeId' => 'string',
'listLabel' => 'Claim Number',
'isRequired' => true,
],
]);
Automatic Element Numbering
A typical task: "Claim No. CL-2024-0042". Implemented through an event handler onCrmDynamicItemBeforeAdd:
AddEventHandler('crm', 'onCrmDynamic' . $entityTypeId . 'ItemBeforeAdd', function(\Bitrix\Main\Event $event) {
$item = $event->getParameter('item');
$year = date('Y');
// Atomic counter in Redis or a table
$seq = incrementSequence("claim_{$year}");
$item->set('UF_CRM_CLAIM_NUMBER', sprintf('CL-%d-%04d', $year, $seq));
});
Related Entities and Cascading Actions
When a claim is created, automatically:
- A task is created for the quality department.
- A related deal is attached (if the claim is for an order).
- The responsible manager is notified.
AddEventHandler('crm', 'onCrmDynamic' . $entityTypeId . 'ItemAdd', function(\Bitrix\Main\Event $event) use ($b24) {
$item = $event->getParameter('item');
$dealId = $item->get('OPPORTUNITY'); // custom field for the linked deal
// Create a task
$b24->callMethod('tasks.task.add', [
'fields' => [
'TITLE' => 'Process claim ' . $item->get('UF_CRM_CLAIM_NUMBER'),
'RESPONSIBLE_ID' => getQualityDeptHead(),
'DEADLINE' => date('Y-m-d\TH:i:s', strtotime('+2 business days')),
'UF_CRM_TASK' => ["D_{$dealId}"],
],
]);
// Notification via bot
notifyManager($item->get('ASSIGNED_BY_ID'), "New claim: " . $item->get('UF_CRM_CLAIM_NUMBER'));
});
Custom Robots for a Smart Process
Robots are actions the CRM performs automatically when a stage changes. Standard robots (send email, create task) — out of the box. A custom robot is created via REST:
$b24->callMethod('bizproc.robot.add', [
'CODE' => 'send_to_1c',
'HANDLER' => 'https://your-server.com/robot/send-to-1c',
'AUTH_USER_ID' => 1,
'NAME' => ['ru' => 'Send to 1C'],
'PROPERTIES' => [
'document_type' => ['Name' => 'Document type', 'Type' => 'select', 'Options' => ['claim' => 'Claim', 'refund' => 'Refund']],
],
'RETURN_PROPERTIES' => [
'external_id' => ['Name' => 'ID in 1C', 'Type' => 'string'],
],
]);
When the CRM executes the robot, B24 POSTs the element data to HANDLER. The handler performs the logic (request to 1C), returns JSON with RETURN_PROPERTIES. B24 writes the returned data to the element's fields.
Custom Card via Placement
The standard smart process card is not always convenient. For a complex UI — embed a custom interface via placement.bind with type CRM_DYNAMIC_DETAIL_TOOLBAR:
$b24->callMethod('placement.bind', [
'PLACEMENT' => 'CRM_DYNAMIC_' . $entityTypeId . '_DETAIL_TOOLBAR',
'HANDLER' => 'https://your-server.com/app/claim-detail',
'TITLE' => 'Additional Data',
]);
Opens as a side panel (slider) in the smart process card — your SPA with a custom interface.
Access Rights
Rights to a smart process are configured through CRM roles (crm.type.userfield.access.set) or through the app. For a complex matrix: read — all managers, edit — only the responsible person and their manager, delete — admins only. Checked via user.current and department.get on every request.
Integration with External Systems
| Direction | Method | Event |
|---|---|---|
| Smart process → 1C | REST handler + custom robot | Stage change |
| 1C → Smart process | crm.item.update via B24 webhook |
Scheduled or triggered in 1C |
| Smart process → Email | event.send or custom robot |
Creation, stage change |
| External service → Smart process | crm.item.add via REST API |
Webhook from external service |
Timelines
| Stage | Timeline |
|---|---|
| Designing the field structure and pipeline | 2–3 days |
| Creating the type and fields via REST/API | 1–2 days |
| Event handlers (numbering, cascade) | 2–4 days |
| Custom robots | 2–3 days each |
| Custom card (SPA in placement) | 3–5 days |
| Integration with external systems | 2–5 days |
| Testing | 2–3 days |
Total: 2–4 weeks depending on the number of robots and whether custom UI is needed.







