Все статьи
Битрикс 31 января 2025 1 мин чтения

BX Rest API. Получить списки отсутствий пользователей

BX24.callMethod(
    'calendar.accessibility.get',
    {
        from: '2024-01-01',
        to: '2024-12-31',
        users: [1, 2, 3]
    },
    function(result) {
        if (result.error()) {
            console.error('Ошибка: ' + result.error());
        } else {
            const data = result.data();
            for (const userId in data) {
                if (data.hasOwnProperty(userId)) {
                    console.log(`Пользователь ID: ${userId}`);
                    const events = data[userId];
                    for (const event of events) {
                        if(event.ACCESSIBILITY === "absent")
                            console.log(`Событие: ${JSON.stringify(event)}`);
                    }
                }
            }
        }
    }
);