Documentation

OnAfterEntityMerge

Elements were successfully merged


OnAfterEntityMerge

The event OnAfterEntityMerge is triggered when merging two entities and is designed for external code to correctly move bindings from deleted element to the merged one.

The following parameters are passed to the event:

ParameterFormatDescription
entityTypeIdintMerged entity type ID. Can receive the following values: 1 (lead), 2 (deal), 3 (contact) or 4 (company).
seedEntityIDintSource element ID for merging.
targetEntityIDintElement ID, targeted for merging.

Example


\Bitrix\Main\EventManager::getInstance()
	->addEventHandler('crm', 'OnAfterEntityMerge', function(\Bitrix\Main\Event $event) {
		$entityTypeId = $event->getParameter('entityTypeID'); 

		if ($entityTypeId == \CCrmOwnerType::Contact)
		{
			// change binding from merged contact to new
			MyCustomLogic::rebindContact(
				$event->getParameter('seedEntityID'),
				$event->getParameter('targetEntityID')
			);
		}
	})
;


© «Bitrix24», 2001-2024
Up