Nested filters in lookup functions how to contain OR condition inside AND

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arturkulik
    Member
    • Apr 2025
    • 76

    #1

    Nested filters in lookup functions how to contain OR condition inside AND

    hello,
    we have perfect function:
    Supporting a nested where clause for formula lookup functions. The where item format is the same as for API requests. Affected functions: record\findOne record\findMany record\findRelatedOne record...


    but i can not contain OR object in 'AND' main type filter ( example idea below)

    the problem is that i connect with OR two different fields attribute1 and attribute2
    (i was using name like '$where','$it','$it2' etc)


    Click image for larger version

Name:	image.png
Views:	0
Size:	126.6 KB
ID:	124309

    the solution is to search 2 times , merge results and do unique
    but it would be easier doing at once like report can


    can You help?
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9620

    #2
    Hi, I don't understand the question.

    In the example, it won't give any result as the first two items are mutually exclusive (within an AND block). It checks that the name equals both 'A1' and 'A2' which is not possible.

    You also need to return the statement inside parentheses at the very end, as the last statement. You don't do it for $where2. The value of the latest statement is returned as the result of the (...) block.

    Note that this syntax is optional, to be able to define a tree like structure in a functional way.

    Comment

    • arturkulik
      Member
      • Apr 2025
      • 76

      #3
      so is it anyway possible to serach like that:
      Click image for larger version

Name:	image.png
Views:	0
Size:	71.7 KB
ID:	124335


      i need to transfer report conditions here:
      ​​Click image for larger version

Name:	image.png
Views:	0
Size:	27.6 KB
ID:	124336

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9620

        #4
        Yes. It is. It looks correct, maybe there are some mistakes if it does not work for you.

        Comment

        • arturkulik
          Member
          • Apr 2025
          • 76

          #5
          THANK YOU! , problem was ","at line 46 (should be " ; " )
          Last edited by arturkulik; 01-30-2026, 08:02 AM.

          Comment

          Working...