if (empty($EMAIL_FROM)) { $arError[] = GetMessage("sender_chain_edit_error_email_from"); } $chainList = array(); if (empty($arError) && !empty($MAILING_TEMPLATE_CODE)) { $presetMailingList = \Bitrix\Sender\MailingTable::getPresetMailingList(array('CODE' => $MAILING_TEMPLATE_CODE)); $presetMailing = current($presetMailingList); if (!empty($presetMailing)) { $arFields['TRIGGER_FIELDS'] = array('START' => $presetMailing['TRIGGER']['START']['ENDPOINT'], 'END' => $presetMailing['TRIGGER']['END']['ENDPOINT']); foreach ($presetMailing['CHAIN'] as $chain) { $chain['EMAIL_FROM'] = $EMAIL_FROM; $chain['CREATED_BY'] = $USER->GetID(); $chainList[] = $chain; } $result = new \Bitrix\Main\Entity\Result(); \Bitrix\Sender\MailingTable::checkFieldsChain($result, null, $chainList); if (!$result->isSuccess()) { $arError = array_merge($arError, $result->getErrorMessages()); } } else { $arError[] = GetMessage("sender_chain_edit_error_tmpl_no_found") . ' "' . $MAILING_TEMPLATE_CODE . '".'; } } if (empty($arError)) { if ($MAILING_ID > 0) { $updateDb = \Bitrix\Sender\MailingTable::update($MAILING_ID, $arFields); if (!$updateDb->isSuccess()) { $arError = array_merge($arError, $updateDb->getErrorMessages()); } } else { $arFields['ACTIVE'] = 'N';