Chrome-SP-Editor icon indicating copy to clipboard operation
Chrome-SP-Editor copied to clipboard

Unable to load _spPageContextInfo in popup.html

Open sankarkumar23 opened this issue 3 years ago • 7 comments

I am getting below error while loading pagecontentinfo in popup.html

image

image

sankarkumar23 avatar Oct 04 '21 07:10 sankarkumar23

Thanks @sankarkumar23 I will have a look!

visma-tomi-tavela avatar Oct 12 '21 11:10 visma-tomi-tavela

@sankarkumar23 which page in SharePoint you got this?

tavikukko avatar Oct 13 '21 08:10 tavikukko

Any SharePoint page. It never worked for me.. the popup.html is not showing the properties. Looks like JSON.stringfy resulting in circular references which is causing the issue.

image

sankarkumar23 avatar Oct 13 '21 09:10 sankarkumar23

Still cannot repro this. Is your SharePoint online/onprem? Which chrome version you are using?

tavikukko avatar Oct 13 '21 10:10 tavikukko

I am trying on SharePoint Online. Chrome version - 94.0.4606.71

sankarkumar23 avatar Oct 13 '21 11:10 sankarkumar23

I noticed it was working fine for some site collections and not for some. It appears its not working for certain site templates.

sankarkumar23 avatar Nov 03 '21 10:11 sankarkumar23

thanks @sankarkumar23 ! Could you try to check what type of SiteCollection is it? That would help me to discover the reason and provide a fix. Cheers!

tavikukko avatar Nov 03 '21 13:11 tavikukko

@tavikukko - Thank you for this extension. I use this almost everyday.

One of the features I like the most is the extension popup which provides links to various SharePoint (system?) pages. That popup works on all pages, however I have seen it not working in the modern list page i.e. if we navigate to any modern list (/sites/contoso/lists/listname) and click on the extension, we do not see the links loading.

We see the below

image

and the error message is similar to the one shared originally earlier

image

Potential fix

It looks like the dataSyncClient property of the _spPageContextInfo is the culprit which is preventing JSON.stringify to run in the getContext function.

So if we remove the dataSyncClient property then JSON.stringify runs fine. A function like below can be used

var removePropertyFromObject = function (propertyName, objectToBeProcessed) { 
    let { [propertyName]: _, ...objectWithoutProperty } = objectToBeProcessed; 
    return objectWithoutProperty; 
}

removePropertyFromObject("dataSyncClient", _spPageContextInfo)

But when this issue was reported, the property causing the error was different (as per the first screenshot when the issue was raised). So, not sure if the fix I have suggested is the right one?

I am using Edge (chromium) version 108.0.1462.54 and 110.0.1556.0 dev .

Happy to provide more information if needed.

anoopt avatar Dec 29 '22 18:12 anoopt

Hi @anoopt Thanks for the fix, I'll apply it and test if it work! Thanks!

tavikukko avatar Dec 30 '22 15:12 tavikukko

The fix worked, it will be part of the next release, which is in Review at the Chrome Store. Thanks and happy new year!

tavikukko avatar Dec 30 '22 16:12 tavikukko