Cross Site Lookup Sorting

Discussions about Cross-site Lookup
Locked
Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

21 Mar 2014

I'm having an issue sorting the Cross Site Lookup. Currently it looks up to a list with no problem but I need it to sort by the company name in the lookup. If you could provide an example of how to change the default sort.


Thank you.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

24 Mar 2014

Hello,

Thank you for your request. Please, open Cross-site Lookup Manager and expand the Advanced settings section. In the Request items area you can find SharePoint data requests. Please, modify $orderby clause by replacing Created field with the internal name of the company name field. Here is an example:

Code: Select all

function (term, page) {
  if (!term || term.length == 0) {
    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id," + 
    "{LookupField}&$orderby=CompanyName&$top=10";
  }
  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id," +
  "{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "')&$top=10";
}

Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

26 Mar 2014

I start with the following code, the dropdown works as expected, no sorting:

function (term, page) {

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

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}";

}

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

}


I make this change and the dropdown always shows "Searching...":

function (term, page) {

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

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}"$orderby=Title;

}

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

}


The column in the looked-up list is the Title field renamed to Relation. Please help.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Mar 2014

Hi,

It seems, you have a syntax error. Please, try to use the following code:

Code: Select all

function (term, page) {

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

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Title";

}

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

}
You can open the browser console and find the description of the error there.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests