Cross-site lookup - 'Loading Failed' error

rss

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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 25 days
    #11 by Dmitry Kozlov Aug 28 ’15 at 03:26

    [#10]: You cannot sort the result set by calculated columns, so, please, use the following snippet:

    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=Title&" +
        "$filter=startswith(Project_x0020_Number, '" + encodeURIComponent(term) + "') or " +
        "startswith(Title, '" + encodeURIComponent(term) + "')&$top=10";
    }
    
  • kevyn
    Member
    Member for: 4 years 11 months 21 days
    #12 by kevyn Aug 28 ’15 at 04:58

    [#11]: This is excellent - thank you so much. My final question - how would you go about adding a 3rd column? (thank you!)

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 25 days
    #13 by Dmitry Kozlov Aug 28 ’15 at 05:02

    [#12]: Do you mean that you need to filter the result set by three fields? If so, here is the 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=Title&" +
        "$filter=startswith(Project_x0020_Number, '" + encodeURIComponent(term) + "') or " +
        "startswith(Title, '" + encodeURIComponent(term) + "') or " +
        "startswith(field3, '" + encodeURIComponent(term) + "')&$top=10";
    }
    
  • kevyn
    Member
    Member for: 4 years 11 months 21 days
    #14 by kevyn Aug 28 ’15 at 05:19

    [#13]: That's what I thought, but it doesn't seem to have any effect (the dropdown only includes 2 fields)

     

    function (term, page) {

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

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

    }

     

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

    "$filter=startswith(Project_x0020_Number, '" + encodeURIComponent(term) + "') or " +

    "startswith(Client_x0020_ID, '" + encodeURIComponent(term) + "') or " +

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

    }

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 25 days
    #15 by Dmitry Kozlov Aug 28 ’15 at 05:22

    [#14]: If you need to display all three fields in the result set, you should join them into a single calculated column or modify the 'Item format' template as described in out blog:

    http://formsdesigner.blogspot.com/2013/07/setting-up-view-of-results-in-cross.html

  • kevyn
    Member
    Member for: 4 years 11 months 21 days
    #16 by kevyn Aug 28 ’15 at 05:40

    [#15]: I'm sorry I thought we already established that a calculated column would not work? Your suggestion in [#13] did not seem to work either... If we can figure out how to get 3 columns into the results set, then we will purchase a licence

  • kevyn
    Member
    Member for: 4 years 11 months 21 days
    #17 by kevyn Aug 28 ’15 at 05:53

    [#15]: Please ignore my previous post - I fixed the issue now by adding hte 3rd column to the calculated column. My mistake. Thanks for all your help :-)

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 25 days
    #18 by Dmitry Kozlov Aug 28 ’15 at 05:54

    [#16]: You can display a calculated column in the drop-down but you cannot search by this field. That is why we built a complex condition in the 'Request items' template. So, if you need to display multiple fields at once, you need to create a calcualted column that joins these fields and select it as a display column in the Lookup Manager. Next, open the Advanced settings and replace {LookupField} in $orderby and $filter clauses with regular fields as I did in the last sample.

Displaying 11 to 18 of 18 messages