Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

Updating Modern page fails after 2nd time #190

Closed
arunakshi opened this issue Oct 26, 2017 · 1 comment
Closed

Updating Modern page fails after 2nd time #190

arunakshi opened this issue Oct 26, 2017 · 1 comment

Comments

@arunakshi
Copy link

arunakshi commented Oct 26, 2017

Repro Steps:

  1. Created a ClientSidePage with ClientSideText control and 2 standard webparts using OfficeDev.Pnp.Core methods.
  2. Update ClientSidePage method.

Actual Result:
I have the scenario like this:
CheckIfPageExists which checks of Page exists, this method works for two times and third time, I am getting: "Object reference not set to an instance of the object" from OfficeDevPnP.Core.Pages.ClientSideText.FromHtml(IElement element)
at OfficeDevPnP.Core.Pages.ClientSidePage.LoadFromHtml(String html)
at OfficeDevPnP.Core.Pages.ClientSidePage.Load(ClientContext cc, String pageName)

My code is like below:

  private static bool CheckIfPageExists(string pageFileName, Web web)
  {      
     // this line fails
       var clientSidePage = ClientSidePage.Load(web.Context.GetSiteCollectionContext(), pageFileName);  
        if (clientSidePage != null)
        {
             return true;
        }
      return false;           
  }

my update method is like this:

 private void UpdatePage(Web web, ProvisioningDescriptor descriptor)
 {
   ClientSideText textContent = new ClientSideText
    {   Text = descriptor.PageContent        };
    if (descriptor.Order != null && descriptor.Order.Value != null)
     {
          clientSidePage.Controls[descriptor.Order.Value].Delete();
           clientSidePage.Save(descriptor.Name);
           clientSidePage.AddControl(textContent, descriptor.Order.Value);
     }
      clientSidePage.Save(descriptor.Name);
 }

I call the CheckIfPageExists method from another method, if CheckIfPageExists returns true I will call UpdatePage.

Anyone has the same problem?

@spdevdocs
Copy link

We closed this issue as it had not activity within last 180 days. This is a generic process we have decided to perform for issues, which have not been explicitly marked still to be "work in progress" based on tags. We are performing this cleaning to make sure that old issues that have already been solved (but not closed) or are no longer relevant are cleaned out and make the issues more manageable. If this issue still valid, we would ask you to open a new issue and follow the guidance in the issue template related on the recommended location. We do apologize any inconveniences this might cause. Please do remember that issues in the issue lists are also messages for others in the community, so you can also check if you can assist on any of them. “Sharing is caring!”

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants