D
D
Dim2020-05-12 16:05:36
1C-Bitrix
Dim, 2020-05-12 16:05:36

How to correctly specify the filter "by occurrence" in the Bitrix code?

In a method that returns a list of objects, what is the correct way to write filter to return results containing $lot_number?

An example of a code where everything works, but works according to the strict correspondence of the contents of the UF_CRM_1580557568 field to the $lot_number variable

Code:

$result = CRest::call(
      'crm.deal.list', 
         [
            'order' => ['STAGE_ID' => 'ASC'],
            'filter' => ['UF_CRM_1580557568' => $lot_number],
            'select' => ["UF_*", "*"]
         ]);


the UF_CRM_1580557568 field and the $lot_number variable are numbers. It is necessary, for example, if the field = 15690, and $lot_number = 156 or 569, then this field should be included in the result.

There are examples of the filter in the documentation, and it is written that you need to use the % symbol to search for a substring, but how and where to insert it? Tried different ways, couldn't get it to work.

Docks https://dev.1c-bitrix.ru/api_help/iblock/filters/s...
https://dev.1c-bitrix.ru/learning/course/index.php...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2020-05-12
@rpsv

You have a piece of when to work with the Rest API when accessing deals, and the documentation is from working with infoblocks. It's like a little bit completely different things.
For rest, as far as I know, there is no substring search, only >,<,<=,>=
So for your case it's not possible to do this.

I
Ilya Tsarenkov, 2021-11-06
@ILX

It worked for me like this

$id=118;
$filter_id = CRest::call('crm.contact.list',['filter' => ['UF_CRM_60EEBF612D269' => $id ]]	);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question