Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I’ve setup up two lists.

A main list(list A) and a secondary list(list B).

These two lists are related through lookupfields, where list B looks up items in list A. On the DispForm.aspx for list A, i’ve added a related list(list B) as a viewpart.

When i open an item on list A, it correctly shows the related items in list B.* enter image description here However, if i open an item on list B and click the lookupfield, the viewpart breaks and gives a correlation error.* enter image description here

Since i’m on SharePoint online, i’m not able to debug any logs.

My question is therefore, is this intended behavioure or is this a bug? I can see that when clicking on list B, the url for the item on list A is different than what visiting list A directly. It would see that going through list B, SharePoint appends a "rootfolder=%2A" or "rootfolder=*" to the end of the url. Removing the characters after "=" fixes the issue.

*(The images are from a norwegian SharePoint, but it would be the same in any other language i guess, the errormessage on the second image is just the ordinary "cannot show this webpart")

share|improve this question
    
Just stabbing in the dark here, but try disabling MDS, maybe it's causing issues. –  wjervis May 27 at 12:39
    
No, that didn't work. I've edited my post and added some screenshots to further explain the issue i'm experiencing. –  Alexander May 30 at 19:39
    
@Alexander Edit would be a good thing –  Benny Skogberg MCSA May 30 at 21:17
    
Are lists A and B on the same site? –  wjervis Jun 1 at 17:47
    
Yes, both lists are on the same site. I also recreated on a clean subsite just to be sure it wasnt any deployed wsp or edited masterpage issue. –  Alexander Jun 1 at 17:49

2 Answers 2

up vote 1 down vote accepted

This fix doesn't work on a list with pagination as the list items in the extra pages are obtained via ajax, so this doesn't correct the links for the rest of the pages (as the js doesn't run again).

You can either get it to run again after someone has clicked to view a different page page buttons (AFTER the ajax has got the data and put it on the page), or I'm just running it every couple of seconds:

$(window).load(function() {

    function fixurls(){
        $('.ms-listviewtable tbody a').each(function() {
            try {
                $(this).attr('onclick',$(this).attr('onclick').replace('RootFolder=*','RootFolder='));
                $(this).attr('href',$(this).attr('href').replace('RootFolder=*','RootFolder='));
            }
            catch(e){
                console.log("Found RootFolder replace exception but ignoring it...");
            }
        });
    }

    function run_fixurls(){
        fixurls();
        setTimeout(run_fixurls, 2000);
    }

    run_fixurls();

});
share|improve this answer
    
Changed the correct answer to yours, since its "more" correct as it handles pagination as well. –  Alexander Sep 9 at 13:20

I made contact with 365 support and they could not figure out directly what happens here, so they assisted with a workaround for it.

To enable this sort of retrospection in the lookups I added https://code.jquery.com/jquery-1.11.1.min.js to SiteAssets aswell as this small script:

$(document).ready(function() {
   $('.ms-listviewtable a').each(function() {
                 $(this).attr('onclick',$(this).attr('onclick').replace('RootFolder=*','RootFolder='));
                 $(this).attr('href',$(this).attr('href').replace('RootFolder=*','RootFolder='));
});});

Now to get this working, I added the following to a scripteditor webpart for "List B"(through the "edit page" link)

<script src="../../SiteAssets/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="../../SiteAssets/changeURL.js" type="text/javascript"></script>

This solves the issue for me, and correct urls are linked between the listsviews.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.