Integrating 1C-Bitrix Web Forms with Bitrix24 CRM
The 1C-Bitrix web forms module (bitrix:main.feedback, bitrix:form.result.new) stores results in the b_form_result table and sends email notifications. Without CRM integration, the data remains in the site's database — managers do not see it in Bitrix24 and communication history is never built.
Two Integration Approaches
Approach 1. Bitrix24 CRM Forms module — a cloud tool that hosts the form on a Bitrix24 subdomain. Data goes directly into CRM. Drawback: the form is on a third-party domain, does not benefit SEO, and styles do not match the site.
Approach 2. Native web forms + handler — the form lives on the site, and when submitted the result is written to b_form_result and simultaneously sent to Bitrix24 via the REST API. This is the correct approach for production.
Web Form Result Handler
Bitrix provides the OnAfterResultAdd event from the form module. Subscribe in init.php:
AddEventHandler('form', 'OnAfterResultAdd', function($formId, $resultId, $fields) {
// Only for the required forms
$targetForms = [3, 7, 12]; // form IDs: inquiry, consultation, partnership
if (!in_array($formId, $targetForms)) return;
$answers = CFormResult::GetDataByID($resultId, [], $arrResult);
$mapped = mapFormAnswers($formId, $answers);
$b24 = new B24Sender(getenv('B24_WEBHOOK_URL'));
$b24->sendLead($mapped);
});
Mapping Form Fields to Lead Fields
Web form fields are stored in b_form_field, answers in b_form_result_answer. The relationship is via FIELD_ID. Mapping is configured in a config:
$formMapping = [
3 => [ // form "Callback request"
'q_name' => 'NAME',
'q_phone' => 'PHONE',
'q_comment' => 'COMMENTS',
'utm_source'=> 'UTM_SOURCE',
],
7 => [ // form "Partnership"
'q_company' => 'COMPANY_TITLE',
'q_contact' => 'NAME',
'q_email' => 'EMAIL',
'q_direction' => 'COMMENTS',
],
];
Case Study: Multi-Step Application Form
Situation. An IT integrator's site with a project application form — 4 steps: project type, budget, timeline, contact details. The standard web forms module stores all answers in b_form_result_answer. The goal: create a qualified lead in Bitrix24 with populated fields and the correct pipeline.
Solution. Steps 1–3 are saved to the session; step 4 submits the complete form. In the OnAfterResultAdd handler, all fields are assembled and a lead is created with custom CRM fields:
$leadFields = [
'TITLE' => 'Project: ' . $answers['project_type'],
'OPPORTUNITY' => $answers['budget_from'], // budget → lead amount
'CURRENCY_ID' => 'USD',
'UF_CRM_PROJECT_TYPE' => $answers['project_type'],
'UF_CRM_DEADLINE_WEEKS' => $answers['deadline'],
// UF_CRM_* — custom lead fields in B24
];
Custom fields (UF_CRM_*) are pre-created in Bitrix24 via crm.userfield.add. After creating the lead, a business process is automatically started in B24 via bizproc.workflow.start.
File Upload Fields in Forms
If a form contains a file upload field (specification, brief), the file must be transferred to Bitrix24. The REST API crm.lead.add does not support direct binary uploads — use disk.folder.uploadfile to upload to the Bitrix24 Drive, then attach to the lead via crm.activity.add with type DOCUMENT.
Lead Deduplication
The same company often submits a form multiple times. Check by email and phone before creating:
$existing = $b24->call('crm.duplicate.findByComm', [
'type' => 'EMAIL',
'values' => [$email],
'entity_type' => 'LEAD',
]);
if (!empty($existing['result']['LEAD'])) {
// Add an activity to the existing lead, do not create a new one
$b24->call('crm.activity.add', [...]);
}
| Task | Effort |
|---|---|
| Handler setup for 1 form | 3–5 h |
| Field mapping + custom B24 fields | 2–4 h |
| Deduplication and repeat submission logic | 4–6 h |
| File transfer from forms | 4–6 h |
| Business process triggers on lead | 3–5 h |







