S
S
Sergey Ch2017-12-18 12:31:38
1C-Bitrix
Sergey Ch, 2017-12-18 12:31:38

Bitrix24 Boxed version, how to create an event via PHP code - reminders in the calendar for a specific date and time?

I am writing a sales script for salespeople, I need to implement the setting of an event in the calendar via php based on the results of the conversation through the form on the script page. In the REST documentation, I found the installation through the REST API and the BX24 library, but as I understand it, this is used for the market application and authentication by token is required.
The developer documentation about the calendar lists only events, but does not describe exactly how to create events.
On the forum for developers, I found an implementation through a business process, but this does not suit me

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Ch, 2017-12-20
@elov4anin

Thanks guys for all the answers, but I decided to post the code differently if anyone needs it

//Устанавливаем дело-звонок и напоминание для сделки
                        $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);
                           
                        }
                        
                       }

V
Vladislav Kvetkin, 2017-12-18
@bdj

You can try using the CCalendar::SaveEventEx method

N
Nikita Ermilichev, 2017-12-19
@Masas

Please specify if you are interested in an event in the calendar? or in CRM entities?
If the former, then look at the CCalendarEvent::Edit() method

D
DRusak, 2021-01-19
@DRusak

$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'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question