1

On SharePoint 2013 On Premise, I need rest api filter where I can search some numbers in list starts with. Since records are around 100,000 I can not display all. Hence need a kind of search function.

5
  • Do you need to filter on single column values...is that right? Commented Aug 28, 2018 at 13:04
  • yes. There is only one number field. I want to search number 123xxx Commented Aug 28, 2018 at 13:07
  • I have added the example in answer section for Title field. similarly you can do for your field. if useful, please up vote. :) Commented Aug 28, 2018 at 13:12
  • You can use startswith on String and not the number. Refer this link - docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/… Commented Aug 28, 2018 at 17:30
  • The work around is you can combine Ge and Le (i.e. greater than equal to and less than equal to) to get the required result. Commented Aug 28, 2018 at 17:33

3 Answers 3

0

You can use the filter on column something like given below:

var endpointUri = appwebUrl + "/_api/web/lists/getbytitle('listName')/items?$select=*&$filter=startswith(Title,'value')";
3
  • I want it on a number field Commented Aug 28, 2018 at 14:13
  • You can use it on number field too.... Just add the internal name of your number field replacing 'Title' and the number you want to search replacing 'value' in above example. Commented Aug 28, 2018 at 18:24
  • have you tried this? Commented Nov 15, 2018 at 12:51
0

Is it a numberfield or a textfield?

If its a numberfield why not create a filter that compares a number greater than the numberfield?

Something like this:

/_api/web/lists/getbytitle('list')/items?$filter=[Numberfield] ge 123000

Where ge is Greater than or equal.

4
  • I think Vikas wants to search the number starting with 123xxx. Not the values greater than that 123xxx. Commented Aug 28, 2018 at 13:26
  • Yeah but as he writes numberfield and not text field I dont really know what he means. He need to clarify if its a number or a textstring he want to search for. Commented Aug 28, 2018 at 13:28
  • I want to search number startswith 123... not greater than Commented Aug 28, 2018 at 14:14
  • You cant cast a number value in SharePoints REST api and therefore not use startswith so i think your only valid option is to use my method where you look for number bigger than the one you are looking for. Commented Aug 28, 2018 at 15:17
0

You can try something like below:

e.g. To get item with the number 444 in numberfield:

/_api/web/lists/getbytitle('testCRUD')/items?$select=*&$filter=(numberfield ge '444') and (numberfield le '444')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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