R
R
Roman Govorov2019-11-06 10:38:09
Bitrix24
Roman Govorov, 2019-11-06 10:38:09

How to determine online responsible (ASSIGNED_BY_ID) or not?

How to determine the online responsible (ASSIGNED_BY_ID) to write the following condition:
There are two users in Bitrix with ID 1 and 2
If 1 user is online then assign him as responsible for the Lead
Otherwise assign 2 users.
Code example:

$queryData = http_build_query(array(
    'fields' => array(
        'TITLE' => $title,
        'NAME' => $fio,
        'EMAIL' => array(
            array(
                "VALUE" => $email
            )
        ),
        'PHONE' => array(
            array(
                "VALUE" => $phone
            )
        ),
        'COMMENTS' => $comments,
        'OPPORTUNITY' => preg_replace('/[^0-9]/', '', $price),
        'UF_CRM_1571212572' => $inn,
        'UF_CRM_1571226484' => $tariff,
        'CURRENCY_ID' => 'RUB',
        'QUANTITY' => 1,
        'SOURCE_ID' => 5,
        'ADDRESS_CITY' => $city,
        'ASSIGNED_BY_ID' => $manager_id
    ),
    'params' => array("REGISTER_SONET_EVENT" => "Y")
));

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Govorov, 2019-11-06
@RGameShow

My implementation, mb to whom it will be useful:

$array = $manager_and_product[$product_id];
$product_id = $array['product_id'];
$manager_id_array = $array['manager_id'];

foreach ($manager_id_array as $id){
    $user_online = file_get_contents('https://XXXXX.bitrix24.ru/rest/ID/XXXXXXXXXXX/user.get.json?IS_ONLINE=Y&id='.$id);
    $user_online = json_decode($user_online, true);
    if(count($user_online['result'][0]) > 0){
        $manager_id = $id;
    }else{
        $manager_id = $manager_id_array[0];
    }
}

A
alex1nd, 2021-08-07
@alex1nd

and how can I write it so that it is alternately evenly distributed, for example, first id 1 then the next lead id2....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question