SharePoint Asked by Misbah on October 25, 2021
We have migrated our site to SharePoint Modern experience from classic. For that we had to replace the Script Editor with the React Script Editor, as Script editor is no longer available in modern experience. Now, we are trying to validate the document/page links after migration by fetching the ServerProcessedContent property for all web parts by using SharePointPnPCoreOnline:
using (ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
{
web = ctx.Web;
//loading sharepoint web instance
ctx.Load(web);
ctx.ExecuteQueryRetry();
sitePagesList = web.Lists.GetByTitle("Site Pages");
CamlQuery query = new CamlQuery();
query.ViewXml = "<View><Query><OrderBy><FieldRef Name = 'ID'/></OrderBy></Query></View>";
var allItems = sitePagesList.GetItems(query);
ctx.Load(allItems, eachItem => eachItem.Include(i => i["DisplayName"]));
ctx.ExecuteQuery();
foreach (var i in allItems)
{
ctx.Load(i, I => I.File, I => I.DisplayName);
ctx.ExecuteQueryRetry();
file = i.File;
file.EnsureProperty(x => x.Name);
var page = ClientSidePage.Load(ctx, file.Name);
var webParts = page.Controls.FindAll(c => c.Type.Name == "ClientSideWebPart");
if (webParts != null && webParts.Count > 0)
{
foreach (var webpart in webParts)
{
try
{
clientSideWebPart = (ClientSideWebPart)webpart;
// This is the property we are trying to get
JObject jsonObject = clientSideWebPart.ServerProcessedContent;
}
catch (Exception ex) { }
}
}
}
}
We are able to get the value for all other webparts, but for React Script Editor there are no results in the ServerProcessedContent property:
{"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}
I tried to do it with CSOM but it didn’t work either. Am I missing something or is there a different way to get the content for react script editor?
Thanks
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP