• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/documentgenerator/dataprovider/crmentitydataprovider.php
  • Класс: Bitrix\Crm\Integration\DocumentGenerator\DataProvider\CrmEntityDataProvider
  • Вызов: CrmEntityDataProvider::getEmailCommunication
public function getEmailCommunication()
{
	$result = [];
	$company = $this->getValue('COMPANY');
	if($company instanceof Company)
	{
		$email = $company->getValue('EMAIL_WORK');
		if(!$email)
		{
			$email = $company->getValue('EMAIL_HOME');
		}
		$result[] = [
			'entityType' => 'COMPANY',
			'entityId' => $company->getSource(),
			'entityTitle' => $company->getValue('TITLE'),
			'type' => 'EMAIL',
			'value' => $email,
		];
	}
	$contact = $this->getValue('CONTACT');
	if($contact instanceof Contact)
	{
		if(!$email)
		{
			$email = $contact->getValue('EMAIL_WORK');
		}
		if(!$email)
		{
			$email = $contact->getValue('EMAIL_HOME');
		}
		$result[] = [
			'entityType' => 'CONTACT',
			'entityId' => $contact->getSource(),
			'entityTitle' => $contact->getValue('FORMATTED_NAME'),
			'type' => 'EMAIL',
			'value' => $email,
		];
	}

	return $result;
}