pnp/PnP

Pnp Provisioning ClientSitePages : Version Conflict

oppie85 opened this issue · 5 comments

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.

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.

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.

@MikeRogersDigital fix resolved the issue for me.

Thanks for this, I had the same issue and found that changing the header type to: <pnp:Header Type="Default" /> 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.

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:
pnp:Files
<pnp:File Src="SiteAssets/__sitelogo__site-logo-white.png" Folder="SiteAssets" Overwrite="true" Level="Draft" />
<pnp:File Src="SiteAssets/baqua-hero-silhouette.png" Folder="SiteAssets" Overwrite="true" Level="Draft" />
</pnp:Files>

Finally you reference these images in your client side page by doing this:
<pnp:Header Type="Custom" ServerRelativeImageUrl="{site}/SiteAssets/baqua-hero-silhouette.png" />

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