【问题标题】:How to implement LIKE(filter) on a list column using Sharepoint Rest API?如何使用 Sharepoint Rest API 在列表列上实现 LIKE(filter)?
【发布时间】:2020-03-03 12:57:44
【问题描述】:
如何使用 REST API 对 SharePoint 列表的列数据实现 LIKE?
有没有办法实现?
现状:
API 工作正常,但期望的结果不是完全匹配。
必填:
所有匹配“约翰”的名字都应该响应。
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);
谢谢!
【问题讨论】:
标签:
jquery
ajax
api
sharepoint
【解决方案1】:
尝试将响应记录到您的控制台并检查记录的数组,
现在尝试使用此过滤器
var URL = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('UserList')/Items?$select=UserName&$filter=substringof('John',UserList);
【解决方案2】:
对于文本文件
/_api/Web/Lists/getByTitle('TestList')/Items?$select=Title&$filter=substringof('John',textField)
对于用户字段
/_api/Web/Lists/getByTitle('TestList')/Items?$select=Title,UserName/Title&$expand=UserName&$filter=substringof('John',UserName/Title)