Page 1 of 1

Filtering Cross-site Lookup

Posted: 14 Feb 2014
by MES5464
Is anyone willing to help me with my cross-site lookup filter?


function (term, page) {

var dt = Date.today();


if (!term || term.length == 0) {

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Occuring,Location&$orderby=Show_x0020_Start,Show_x0020_End&$filter=year(Show_x0020_Start) eq " + dt.getFullYear() + "&$top=100";

}

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Occuring,Location&$orderby=Show_x0020_Start,Show_x0020_End&$filter=startswith({LookupField}, '" + term + "')&$top=100";

}

Re: Filtering Cross-site Lookup

Posted: 14 Feb 2014
by MES5464
I have been experamenting with other ways to get what I need. While doing so I have attempted to use endswith and substringof in both cases I get the following messages:

The function operator 'endswith' is not not supported or its usage is invalid.

The function operator 'substringof' is not not supported or its usage is invalid.

Re: Filtering Cross-site Lookup

Posted: 14 Feb 2014
by MES5464
Some of the things I have tried.

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Occuring,Location&$orderby=Show_x0020_Start,Show_x0020_End&$filter=endswith({LookupField}, '2014')&$top=100";


return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Occuring,Location&$orderby=Show_x0020_Start,Show_x0020_End&$filter=substringof({LookupField}, '2014')&$top=100";

Re: Filtering Cross-site Lookup

Posted: 16 Feb 2014
by Dmitry Kozlov
Hello,

It seems, MSDN guidance contains incorrect samples. Try the following code:

Code: Select all

function (term, page) {
  var dt = new Date();
  if (!term || term.length == 0) {
    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,\  
    {LookupField},Occuring,Location&$orderby=Show_x0020_Start,Show_x0020_End&\
    $filter=Show_x0020_Start gt datetime'" + dt.getFullYear() + "-01-01T00:00:00Z'&$top=100";
  }
...
}
Please, read the following article:
http://neganov.blogspot.ru/2013/06/filt ... using.html

Re: Filtering Cross-site Lookup

Posted: 17 Feb 2014
by MES5464
Thank you!