Answer the question
In order to leave comments, you need to log in
How to set a filter with complex logic for CcrmCompany in Bitrix?
In our entity Company, we use 2 user binding fields:
1) Standard field Responsible
2) Custom field
We need to make a selection that the user with ID 1526 is in any of the fields.
I tried to write a classic theme in different ways as in infoblocks:
$res = CCrmCompany::GetList(['DATE_MODIFY' => 'DESC'], ], ['ASSIGNED_BY', 'UF_CRM_1444399075', 'ID'], 5);
while($item = $res->Fetch())
{
pre($item);
}
Answer the question
In order to leave comments, you need to log in
Does the request work out by itself? Is the filter not working? In my opinion, the values of the logical filter should not be in an array, try this:
$res = CCrmCompany::GetList(['DATE_MODIFY' => 'DESC'], , ['ASSIGNED_BY', 'UF_CRM_1444399075', 'ID'], 5);
Set the last parameter to false instead of 5 and get all records instead of the first 5.
quote from the site
https://forwww.com/how-to-use-filter-in-bitrix/
If you use arFilter and arSelect in scripts, you will exclude unnecessary data
. In fact, this code:
Array("ID" => "ASC ", " ACTIVE" => "Y"),
Array("IBLOCK_ID" => 14, 'PROPERTY_SALELEADER_VALUE' => 'yes'),
false,
false,
Array('ID', 'NAME', 'CODE')
visually shows that we will not pass anything extra (it is important not only to specify the conditions in the filter, but also only those fields that you will use, arSelect, or in this case the last array). You need to write "more-less" in this way:
'>=CATALOG_PRICE_1' => '250',
For other conditions - similarly, we write before the property >, <, >=, <=, ! and voila.
How to write a filter with complex 1C-Bitrix logic
Here we come to the most interesting and not obvious. A complex filter can take 2 values AND and OR (AND and OR). At the same time, the complexity of the condition, again, is limited only by your imagination. Without going too far, let's take an example from the documentation:
$arFilter = array(
"IBLOCK_ID" => $IBLOCK_ID,
"SECTION_CODE" => "orange",
"INCLUDE_SUBSECTIONS" => "Y",
array(
"LOGIC" => "OR ",
array(" 50, "=PROPERTY_CONDITION" => "Y"),
array(">=PROPERTY_RADIUS" => 50, "!=PROPERTY_CONDITION" => "Y"),
),
So, for a complex filter, we need to create an array, set the LOGIC value to OR or AND, and after the comma create 2 compared arrays. As you can see, there are almost all the conditions that we talked about above (less than, equal to, greater than or equal to, not equal to).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question