Tuesday, February 28, 2017

Filter on multible coluFilter on multiple columns in SharePoint rest API

I’m build a small JavaScript/REST base application for a customer. Where we to filter on three columns. Filter on one column is easy and straight forward. $filter=MyColumn eq 'myvalue’. But filtering on multiple columns is not as apparent. When I was read the documentation on it. It seems you need to add $filter multiple time to the query. But that is not true. The $filter operator shall only be added one time. Insert added AND/OR between them yours filters. Like $filter=MyColumn1 eq 'myvalue’ AND MyColumn2 eq ‘myvalue’. Or in my case, where I need to find an item between a minimal value and a maximum value.

"$filter=BodyRef eq '" + result + "' and Min le '" + size + "' and Max ge '" + size + "'"

No comments:

Post a Comment