• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Factory/SmartDocument.php
  • Класс: Bitrix\Crm\Service\Factory\SmartDocument
  • Вызов: SmartDocument::createTypeIfNotExists
static function createTypeIfNotExists(): void
{
	$type = TypeTable::getByEntityTypeId(\CCrmOwnerType::SmartDocument)->fetchObject();
	if ($type)
	{
		return;
	}

	Container::getInstance()->getLocalization()->loadMessages();

	$type =
		TypeTable::createObject()
			->setName('SmartDocument')
			->setEntityTypeId(\CCrmOwnerType::SmartDocument)
			->setTitle(Loc::getMessage('CRM_TYPE_SMART_DOCUMENT_TYPE_TITLE'))
			->setCode('BX_SMART_DOCUMENT')
			->setCreatedBy(0)
			->setIsCategoriesEnabled(false)
			->setIsStagesEnabled(true)
			->setIsBeginCloseDatesEnabled(true)
			->setIsClientEnabled(true)
			->setIsUseInUserfieldEnabled(false)
			->setIsLinkWithProductsEnabled(true)
			->setIsCrmTrackingEnabled(true)
			->setIsMycompanyEnabled(true)
			->setIsDocumentsEnabled(false)
			->setIsSourceEnabled(true)
			->setIsObserversEnabled(true)
			->setIsRecyclebinEnabled(false)
			->setIsAutomationEnabled(true)
			->setIsBizProcEnabled(true)
			->setIsPaymentsEnabled(false)
			->setIsSetOpenPermissions(false)
	;

	/** @var AddResult $result */
	$result = $type->save();
	if ($result->isSuccess())
	{
		// this call creates additional type info. now it's not needed, but it is required for complete signing scenario
		// may be this call will be uncommented later
		// \Bitrix\Crm\Settings\Crm::setDocumentSigningEnabled(true);
	}

	if (!$result->isSuccess())
	{
		AddMessage2Log(
			'Error while trying to create SmartDocument type: ' . implode(', ', $result->getErrorMessages()),
			'crm',
		);
	}
}