A
A
Andrey2020-05-13 13:44:03
Bitrix24
Andrey, 2020-05-13 13:44:03

Does the Bitrix24 REST API have an OR operator for crm.deal.list filters?

The task arose - it is necessary to search for deals with filtering by two fields. That is, I need to find all the results where the UF_CRM_***1 or UF_CRM_***2 field contains a substring. I send the following array:

$params = [ 
  'order'	=> [
    'STAGE_ID'	=> 'ASC'
  ],
  'filter'	=> [
    [
      'LOGIC' => 'OR',
      'UF_CRM_***1' => trim( $_GET['proposal'] ),
      'UF_CRM_***2' => trim( $_GET['proposal'] )
    ]
  ],
  'select'	=> [ 'COMPANY_ID', 'STAGE_ID', 'UF_CRM_***'1, 'UF_CRM_***'2, 'DATE_MODIFY' ]
];


but judging by the fact that all results are returned, the filter does not work correctly. The documentation is rather stingy on this topic, perhaps someone has already come across this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2020-05-13
Shults @noroots

Good afternoon!
In the rest API, this feature is not implemented, in such cases I used the batch method batch .

A
Andrey Schultz, 2020-05-16
@noroots

Since the documentation does not really help to make a request, I'll post the solution here.

$params = [
  'cmd' => [
        'kp_num' => 'crm.deal.list?' . http_build_query(
      [
        'filter'	=>  [
          'UF_CRM_***' => '111',
        ],
        'select'	=> [
          'ID',
          'COMPANY_ID',
          'STAGE_ID',
          'UF_CRM_***',
          'DATE_MODIFY'
        ]
      ]
    ),
        'ord_num' => 'crm.deal.list?' . http_build_query(
      [
        'filter'	=>  [
          'UF_CRM_***' => '222',
        ],
        'select'	=> [
          'ID',
          'COMPANY_ID',
          'STAGE_ID',
          'UF_CRM_***,
          'DATE_MODIFY'
        ]
      ]
    ),
  ]
];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question