//Устанавливаем дело-звонок и напоминание для сделки
$arFieldsDelo = array(
'TYPE_ID' => CCrmActivityType::Call,
'PROVIDER_ID' => 'VOXIMPLANT_CALL',
'ASSOCIATED_ENTITY_ID' => $_GET['deal'],
'SUBJECT' => "Тема",
'COMPLETED' => 'N',
'RESPONSIBLE_ID' => "ID отвественного",
'NOTIFY_TYPE' => \CCrmActivityNotifyType::Min,
'NOTIFY_VALUE' => 20,
'DESCRIPTION' => "Описание",
'START_TIME' => $_GET['datetime'],
'END_TIME' => $_GET['datetime'],
'PRIORITY' => CCrmActivityPriority::Medium,
'AUTHOR_ID' => $_GET['assigned'],
'ORIGIN_ID' => 'XYZ_1',
'DIRECTION' => CCrmActivityDirection::Outgoing,
'OWNER_ID' => $_GET['deal'],
'OWNER_TYPE_ID' => CCrmOwnerType::Deal,
);
$arComms = array(
array(
'ID' => 0,
'TYPE' => 'PHONE',
'VALUE' => $_GET['contactTel'],
'ENTITY_ID' => $_GET['deal'],
'ENTITY_TYPE_ID' => 'DEAL'
)
);
$ID = CCrmActivity::Add($arFieldsDelo, false, true, array('REGISTER_SONET_EVENT' => false));
if($ID > 0)
{
//сохраняем дело в календарь
CCrmActivity::SaveCommunications($ID, $arComms, $arFieldsDelo, true, false);
}
}
$arParam = [
'arFields' => [
'ID' => $id, // or 0 for add new event
'OWNER_ID' => 5,// group 5
'SECT_ID' => 13, // group 5
'ATTENDEES_CODES' => ['U'.$userId],
'CREATED_BY' => $userId,
'IS_MEETING' => true,
'SKIP_TIME' => false,
'CAL_TYPE' => 'group', // 'user', 'company_calendar', 'events'
'TZ_FROM' => 'America/Atikokan',
'TZ_TO' => 'America/Atikokan',
'DATE_FROM' => $from, // 01/19/2021 12:00
'DATE_TO' => $to, // 01/19/2021 14:00
'NAME' => $name,
'DESCRIPTION' => $text,
],
'userId' => $userId,
'checkPermission' => false,
];
$resId = CCalendar::SaveEventEx($arParam)['id'];