Cross-site lookup - 'Loading Failed' error
Posted by kevyn - Aug 26 ’15 at 09:01
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?
-
Dmitry KozlovAdminMember for: 9 years 8 months 16 days
Please, open the browser console (F12). Do any notifications appear there while you're typing?
-
kevynMemberMember for: 7 years 9 months 12 days
[#1]: The console shows:
GET https://mydomain.sharepoint.com/sites/beta/_api/web/lists('%7B…swith(Project_x0020_Number_x0020_and_x,%20%27t%27)&$top=10&_=1440601055288 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
-
Dmitry KozlovAdminMember for: 9 years 8 months 16 days
[#2]: Did you modify Request items in the Lookup Manager? Please, try to reset it.
-
kevynMemberMember for: 7 years 9 months 12 days
[#3]: I did not edit the advanced options
-
kevynMemberMember for: 7 years 9 months 12 days
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
-
kevynMemberMember for: 7 years 9 months 12 days
[#3]: it seems any kind of calculated field does not work - is this a bug?
-
Dmitry KozlovAdminMember for: 9 years 8 months 16 days
[#6]: 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:
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"; }
-
kevynMemberMember for: 7 years 9 months 12 days
[#7]: 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";
}
-
Dmitry KozlovAdminMember for: 9 years 8 months 16 days
[#8]: Hi,
You need to use internal names of fields instead of titles:
-
kevynMemberMember for: 7 years 9 months 12 days
[#9]: The URLs are as follows:
column 1 is:
beta/_layouts/15/FldEdit.aspx?List=%7B44B4850F-54F9-46F5-AA7D-F35E9CDD2C2D%7D&Field=Project_x0020_Number
column 2 is:
beta/_layouts/15/FldEdit.aspx?List=%7B44B4850F-54F9-46F5-AA7D-F35E9CDD2C2D%7D&Field=Title
Therefore my new code is:
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_x0020_Number, '" + encodeURIComponent(term) + "') or " +
"startswith(Title, '" + encodeURIComponent(term) + "')&$top=10";
}
However I still get the same error - is there anything you can suggest please?