- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_field_multi.php
- Класс: \CCrmFieldMulti
- Вызов: CCrmFieldMulti::Rebind
static function Rebind($srcEntityID, $srcElementID, $dstEntityID, $dstElementID)
{
if(!(is_string($srcEntityID) && $srcEntityID !== ''))
{
throw new \Bitrix\Main\ArgumentException('Must be not empty string.', 'srcEntityID');
}
if(!(is_string($dstEntityID) && $dstEntityID !== ''))
{
throw new \Bitrix\Main\ArgumentException('Must be not empty string.', 'dstEntityID');
}
if(!is_int($srcElementID))
{
$srcElementID = (int)$srcElementID;
}
if($srcElementID <= 0)
{
throw new \Bitrix\Main\ArgumentException('Must be greater than zero.', 'srcElementID');
}
if(!is_int($dstElementID))
{
$dstElementID = (int)$dstElementID;
}
if($dstElementID <= 0)
{
throw new \Bitrix\Main\ArgumentException('Must be greater than zero.', 'dstElementID');
}
$connection = \Bitrix\Main\Application::getInstance()->getConnection();
$helper = $connection->getSqlHelper();
$srcEntityID = $helper->forSql($srcEntityID);
$dstEntityID = $helper->forSql($dstEntityID);
$connection->queryExecute("
UPDATE b_crm_field_multi SET ENTITY_ID = '{$dstEntityID}', ELEMENT_ID = {$dstElementID}
WHERE ENTITY_ID = '{$srcEntityID}' AND ELEMENT_ID = {$srcElementID}
");
DuplicateCommunicationCriterion::processMultifieldsChange(
CCrmOwnerType::ResolveID($srcEntityID),
$srcElementID
);
DuplicateCommunicationCriterion::processMultifieldsChange(
CCrmOwnerType::ResolveID($dstEntityID),
$dstElementID
);
}