skip to Main Content

How to implement LIKE on a column data of SharePoint list using REST API?
Is there a way to achieve it?

Current Situation:

The API is working fine but the desired result is not to have the exact match.

Required:

All the names matching ‘John’ should come in response.

var URL = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('UserList')/Items?$select=UserName&$filter=UserName eq 'John')";
var response = $.ajax({type: "GET", url: URL, async: false, dataType: "json"}).responseText;
var x = jQuery.parseJSON(response);
console.log(x);

Thanks!

2

Answers


  1. try to log the response to your console and inspect the logged array,
    now try to use this filter

    var URL = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('UserList')/Items?$select=UserName&$filter=substringof('John',UserList);
    
    Login or Signup to reply.
  2. For text filed

    /_api/Web/Lists/getByTitle('TestList')/Items?$select=Title&$filter=substringof('John',textField)
    

    For User field

    /_api/Web/Lists/getByTitle('TestList')/Items?$select=Title,UserName/Title&$expand=UserName&$filter=substringof('John',UserName/Title)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search