1

I am calling rest uri from jQuery ajax with filter string comparison startswith as below

/_api/lists/getbytitle('Stations')/items?$select=Id,City_Code,City_Name_EN&$filter=startswith(City_Name_EN,'M') and Active eq 1&$orderby=City_Name_EN asc

Which is working very good. And I am displaying text by programmatically as below

Mumbai(Mum) i.e. City_Name_EN (City_Code)

but is there anyway to filter startwith(City_Name_EN (City_Code),'M') .

I tried to make calculated field in above format. But rest api does not allow to filter calculated field.

Is there any way to filter like that.

  • in my case spaces are separated by x0020 so Serial_x0020_Number in ODATA url works and not %20 or space and comma – Iman Abidi Sep 21 '15 at 17:44
1

It's not clear exactly what you want to do, but OData $filter has a startswith that you should be able to use here.

$filter=startswith(City_Name_EN,'M')

See this page: http://msdn.microsoft.com/en-us/library/ff798339.aspx and do a find for "startswith".

When in doubt, check the OData spec. SharePoint implements it for the most part, though there are exceptions, e.g., batching.

  • Thank you for the reply. I am very well aware of startswith operator but my requirement is I want filter two fields as a One string For example, City,City_code which I display like "new york (ny)" and I want filter that – Milind Sep 29 '14 at 3:28
  • Can't you just 'and' or 'or' the two conditions, as in this post from Sahil Malik? blah.winsmarts.com/… – Marc D Anderson Sep 29 '14 at 10:06
  • I could have done with 'or' or 'and' but I am using it in jQuery ui auto-complete – Milind Sep 29 '14 at 11:03
  • I don't think you've explained the problem you're trying to solve well then. Are you trying to filter based on a selected value? – Marc D Anderson Sep 29 '14 at 14:59
  • No I am trying to filter based on selected text not value – Milind Sep 30 '14 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.