Cross-site lookup - 'Loading Failed' error

Discussions about Cross-site Lookup
kevyn
Posts: 25
Joined: Wed Aug 26, 2015

26 Aug 2015

Hi there. I just installed a trial of Cross-site lookup for Sharepoint online (office 365) and added a new lookup to a list.


When I click the dropdown, it inputs all of the items from my list successfully, however if I try and enter text to search, it just says 'Loading error'

Please can anyone help?

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

26 Aug 2015

Please, open the browser console (F12). Do any notifications appear there while you're typing?

kevyn
Posts: 25
Joined: Wed Aug 26, 2015

26 Aug 2015

The console shows:

GET https://mydomain.sharepoint.com/sites/b ... 0601055288 400 (Bad Request)


this only happens when typing - if I use the mouse to select items from the drop down without searching it works ok

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

26 Aug 2015

Did you modify Request items in the Lookup Manager? Please, try to reset it.

kevyn
Posts: 25
Joined: Wed Aug 26, 2015

26 Aug 2015

I did not edit the advanced options

kevyn
Posts: 25
Joined: Wed Aug 26, 2015

26 Aug 2015

I think I can now see the problem - the column I'm using is a calculated column with the following value:


=[Project Number]&" - "&[Project Name]


It seems that the search will not work with this calculated column (if I change it to a regular list item it works).

Is there any work around for this please? thanks for your help

kevyn
Posts: 25
Joined: Wed Aug 26, 2015

26 Aug 2015

it seems any kind of calculated field does not work - is this a bug?

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

27 Aug 2015

It seems that SharePoint REST api does not allow to filter by calculated fields but you can configure filtering by multiple regular fields with the help of 'Request item' template following way:

Code: Select all

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=startswith(field1, '" + encodeURIComponent(term) + "') or " +
    "startswith(field2, '" + encodeURIComponent(term) + "')&$top=10";
}

kevyn
Posts: 25
Joined: Wed Aug 26, 2015

27 Aug 2015

Ok so using your example, I replaced 'field1' and 'field2' with my column names from the lookup list, however I got the same results. Is there any other area I should replace?:


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=startswith(Project Number, '" + encodeURIComponent(term) + "') or " +

"startswith(Project Name, '" + encodeURIComponent(term) + "')&$top=10";

}

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

27 Aug 2015

Hi,

You need to use internal names of fields instead of titles:

https://social.msdn.microsoft.com/Forum ... oint-lists

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests