pnp / PnP

SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
https://aka.ms/m365pnp
Other
1.9k stars 3.31k forks source link

Pnp Provisioning ClientSitePages : Version Conflict #1851

Open oppie85 opened 5 years ago

oppie85 commented 5 years ago

Category

[*] Bug [ ] Enhancement

Environment

[*] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Expected or Desired Behavior

I'm attempting to provision multiple ClientSidePages in a single ProvisioningTemplate object loaded from an XML file. All the ClientSidePages should be created with their content one after the other.

Observed Behavior

When applying the template to a site (any site on multiple tenants have been tested) it provisions the first 2 or 3 pages correctly, and then throws a Microsoft.SharePoint.Client.ServerException with the message "Version Conflict". Strangely enough, when I edit the template such that it only provisions one single page, even the ones that previously generated the errors now work correctly. I'm using the NuGet package SharePointPnPCoreOnline version 3.6.1902.

Steps to Reproduce

Create a ProvisioningTemplate with about 10 ClientSitePage objects and apply the template to any site. After the first few pages are processed correctly you should get a Version Conflict error.

oppie85 commented 5 years ago

Additional information; it seems like information is being cached in the ClientContext - I've tried working around this issue by automatically splitting the template into unique templates for each page and applying those successively, but even then the error occurs. When I do the same thing but apply each template in its own isolated ClientContext, the error does not occur.

MikeRogersDigital commented 5 years ago

I'm seeing the same error, it seems to be related to setting a custom header image. If I remove the ServerRelativeImageUrl value from the template all pages create themselves just fine.

jaywellings commented 5 years ago

@MikeRogersDigital fix resolved the issue for me.

mag210 commented 5 years ago

Thanks for this, I had the same issue and found that changing the header type to: allowed the template to compile. I guess this does raise the question as to how you include header images in templated pages. At the moment we are having to run a separate PowerShell script to do this post template.

mag210 commented 5 years ago

Done some more digging into this and you can include header images in your pages. When you get your template you need to make sure that you include -PersistBrandingFiles This fetches the site assets folder. In the folder add in some files, then reference them in the XML like so:

Finally you reference these images in your client side page by doing this: When you apply your template you will see the images you have defined in your template in the site assets folder and any page which references them will have the images already set. Hope this helps, -Max