Hi,
How can I use contains instead of startswith filter the lookup field result .
Hi,
How can I use contains instead of startswith filter the lookup field result .
Thanks for the answer,
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=substringof('and',Title)&$top=10
here is the code, but it is not working properly, it doesn't matter what am I searching for it is showing one result all the time.
Hello @pantea_gooshe,
You need to change both lines of the code in the Request items sections, for instance like this:
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Created desc&$filter=substringof('and',Title)&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "') and substringof('and',Title)&$top=10";
}
Just for the future, questions regarding Cross-Site lookup are better answered in the official forum here - https://spform.com/forum/
But it is still not working properly:
as you can see in the picture if I search for Business it doesn't find anything
Please try out this code:
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=substringof('" + encodeURIComponent(term) + "',{LookupField})&$top=10";
}
Thank you so much, that works