API Rest - Advanced filtering with OR expression

Hello,

I would like to retrieve form submissions depending on two fields, using an OR expression.

First, I can filter on one field value with the following request:

{{base_uri}}/api/forms/{{form_id}}/submissions?where[0][col]=r.field&where[0][expr]=like&where[0][val]=%value%

This works well. Now I want to search on an other field value if the first one does not match (OR expression). I cannot find how to do this.

I tried this:

{{base_uri}}/api/forms/{{form_id}}/submissions?where[0][col]=r.field&where[0][expr]=like&where[0][val]=%value%&where[1][col]=r.field2&where[1][expr]=like&where[1][val]=%value2%

But it obviously does not work because it uses an AND operator I guess.

And this:

{{base_uri}}/api/forms/{{form_id}}/submissions?where[0][col]=r.field&where[0][expr]=like&where[0][val]=%value%&orWhere[0][col]=r.field2&orWhere[0][expr]=like&orWhere[0][val]=%value2%

But it seems that my query parameter orWhere is not taken into account.

Do you know how can I achieve this ?

Thank you for your time.

I haven’t tested it, but it seems that the API Library has an “orX” option:

It’s an alias for the Doctrine’s orX method:

Let us know if it works, please.

I do not use the API Library but simply use cURL. However, I installed and tested it to determine how the query parameters were set when using the orX method. This allowed me to obtain this result which works:

{{base_uri}}/api/forms/{{form_id}}/submissions?where[0][expr]=orX&where[0][val][0][col]=r.field&where[0][val][0][expr]=like&where[0][val][0][val]=%value1%&where[0][val][1][col]=r.field&where[0][val][1][expr]=like&where[0][val][1][val]=%value2%

Thank you for helping @escopecz

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.