• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/widget/formhandler.php
  • Класс: BitrixImOpenLinesWidgetFormHandler
  • Вызов: FormHandler::addLinesBindingToCrm
private function addLinesBindingToCrm(): bool
{
	$imolCode = 'imol|' . $this->userCode;

	$multiFields = ['IM' => []];
	$communicationType = CrmCommon::getCommunicationType($this->userCode);
	$multiFields['IM'][$communicationType][] = $imolCode;
	$fieldsToUpdate['FM'] = CrmCommon::formatMultifieldFields($multiFields);

	$entityToUpdate = null;
	foreach ($this->crmEntities as $entity)
	{
		if ($entity['ENTITY_TYPE'] === Crm::ENTITY_LEAD || $entity['ENTITY_TYPE'] === Crm::ENTITY_CONTACT)
		{
			$entityToUpdate = [
				'TYPE' => $entity['ENTITY_TYPE'],
				'ID' => $entity['ENTITY_ID']
			];
		}
	}

	if (!$entityToUpdate)
	{
		return false;
	}

	CrmCommon::update($entityToUpdate['TYPE'], $entityToUpdate['ID'], $fieldsToUpdate);

	return true;
}