pnpframework: Invalid data has been used to update the list item with pnp:ClientSidePage
I am trying to deploy a page template as part of my provisioning template, however when I create a new instance of the the page template after provisioning a new site, am getting this error:
Invalid data has been used to update the list item. The field you are trying to update may be read only.
I have a page content type that inherits from Site Page, with no additional columns, deployed with my provisioning template, its ID is:
0x0101009D1CB255DA76424F860D91F20E6C411800CDB5E46C6094554D9A67815F1F98AB89
First, I have prepared everything in the site using the browser. I created a content type inheriting from “Site Page”, then created a new page using this content type, and saved it as a template. The page template works fine in the original site when I try to create new instances, so I used Get-PnPProvisioningTemplate
The ClientSidePage XML looks like this, it gives me the error above, if I remove the ContentTypeID from the XML, it works fine:
<pnp:ClientSidePage PromoteAsNewsArticle="false" PromoteAsTemplate="true" Overwrite="true" Title="Custom Page Template" ContentTypeID="0x0101009D1CB255DA76424F860D91F20E6C411800CDB5E46C6094554D9A67815F1F98AB89" ThumbnailUrl="" PageName="Templates/MyPageTemplate.aspx">
<pnp:Header Type="Custom" ServerRelativeImageUrl="https://{fqdn}{site}/SiteAssets/custom/banner.jpg" TranslateX="51.7085751128304" TranslateY="42.1052631578947" LayoutType="FullWidthImage" TextAlignment="Center" ShowTopicHeader="false" ShowPublishDate="false" TopicHeader="" AlternativeText="" Authors="[]" AuthorByLine="[]" AuthorByLineId="-1" />
<pnp:Sections>
<pnp:Section Order="1" Type="OneColumn">
<pnp:Controls>
<pnp:CanvasControl WebPartType="Text" ControlId="9d15f343-b007-415c-b6e7-580e81dc234e" Order="1" Column="1">
<pnp:CanvasControlProperties>
<pnp:CanvasControlProperty Key="Text" Value="Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur" />
</pnp:CanvasControlProperties>
</pnp:CanvasControl>
<pnp:CanvasControl WebPartType="ImageGallery" JsonControlData="{"id": "af8be689-990e-492a-81f7-ba3e4cd3ed9c", "instanceId": "76f685e6-c4f4-43b9-ab85-e0670b668c3d", "title": "Page Template", "description": "Using page template description", "dataVersion": "1.8", "properties": {"layout":4,"carouselSettings":{"autoplay":false,"autoplaySpeed":5,"dots":false,"lazyLoad":true,"metadata":true,"swipe":true},"gridSettings":{"imageSize":2,"imageCropping":1,"imageAspectRatio":1,"lightbox":false},"imageSourceType":1,"isRecursive":false,"isCdnEnabledForList":false,"hasDynamicModeEnabled":false,"maxImagesCount":10,"images":[],"canAlwaysSelectDocLibAsSource":false,"layoutComponentId":""}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="af8be689-990e-492a-81f7-ba3e4cd3ed9c" Order="2" Column="1" />
</pnp:Controls>
</pnp:Section>
</pnp:Sections>
</pnp:ClientSidePage>
My Content Type that is included in the template looks like this:
<pnp:ContentType ID="0x0101009D1CB255DA76424F860D91F20E6C411800CDB5E46C6094554D9A67815F1F98AB89" Name="Custom CT" Description="" Group="Custom" NewFormUrl="" EditFormUrl="" DisplayFormUrl="">
<pnp:FieldRefs>
<pnp:FieldRef ID="c042a256-787d-4a6f-8a8a-cf6ab767f12d" Name="ContentType" UpdateChildren="true" />
<pnp:FieldRef ID="5f47e085-2150-41dc-b661-442f3027f552" Name="SelectFilename" UpdateChildren="true" />
<pnp:FieldRef ID="8553196d-ec8d-4564-9861-3dbe931050c8" Name="FileLeafRef" Required="true" UpdateChildren="true" />
<pnp:FieldRef ID="8c06beca-0777-48f7-91c7-6da68bc07b69" Name="Created" Hidden="true" UpdateChildren="true" />
<pnp:FieldRef ID="fa564e0f-0c70-4ab9-b863-0177e6ddd247" Name="Title" UpdateChildren="true" />
<pnp:FieldRef ID="28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f" Name="Modified" Hidden="true" UpdateChildren="true" />
<pnp:FieldRef ID="822c78e3-1ea9-4943-b449-57863ad33ca9" Name="Modified_x0020_By" UpdateChildren="true" />
<pnp:FieldRef ID="4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb" Name="Created_x0020_By" UpdateChildren="true" />
<pnp:FieldRef ID="82642ec8-ef9b-478f-acf9-31f7d45fbc31" Name="LinkTitle" UpdateChildren="true" />
<pnp:FieldRef ID="7efc33c1-b56b-490e-9c9b-1097e971ba96" Name="ClientSideApplicationId" UpdateChildren="true" />
<pnp:FieldRef ID="daef58d7-ccfd-43fc-b776-2e292cc66bba" Name="PageLayoutType" UpdateChildren="true" />
<pnp:FieldRef ID="4966388e-6e12-4bc6-8990-5b5b66153eae" Name="CanvasContent1" UpdateChildren="true" />
<pnp:FieldRef ID="5baf6db5-9d25-4738-b15e-db5789298e82" Name="BannerImageUrl" UpdateChildren="true" />
<pnp:FieldRef ID="fb3259ac-bd07-4397-b7aa-03e885b0838e" Name="BannerImageOffset" UpdateChildren="true" />
<pnp:FieldRef ID="3f155110-a6a2-4d70-926c-94648101f0e8" Name="Description" UpdateChildren="true" />
<pnp:FieldRef ID="f5ad16a2-85be-46b2-b5f0-2bb8b4a5074a" Name="PromotedState" UpdateChildren="true" />
<pnp:FieldRef ID="c84f8697-331e-457d-884a-c4fb8f30ea74" Name="FirstPublishedDate" UpdateChildren="true" />
<pnp:FieldRef ID="261075db-0525-4fb8-a6ea-772014186599" Name="LayoutWebpartsContent" UpdateChildren="true" />
<pnp:FieldRef ID="1a7348e7-1bb7-4a47-9790-088e7cb20b58" Name="_AuthorByline" UpdateChildren="true" />
<pnp:FieldRef ID="d60d65ff-ff42-4044-a684-ac3f7a5e598c" Name="_TopicHeader" UpdateChildren="true" />
<pnp:FieldRef ID="9de685c5-fdf5-4319-b987-3edf55efb36f" Name="_SPSitePageFlags" UpdateChildren="true" />
</pnp:FieldRefs>
<pnp:DocumentTemplate TargetName="/_layouts/15/CreateSitePage.aspx" />
</pnp:ContentType>
Whenever I create a new page out of this page template that’s connected to this content type, it gives me the reported error.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 43 (14 by maintainers)
@brittanyru Thank you for posting this issue. Experiencing the same thing with our clients environments regarding our custom content types. Everything worked fine up until last Friday. Removing all of our custom fields from the CT and matching them 1 for 1 with site page, still gives us the same issue when creating a new page and saving: “Invalid data has been used to update the list item”.
sorry for the late update. it’s working fine now. thank you all!
@czullu : think your issue is something else as this problem was about issues with users creating pages from page templates with custom content type provisioned via the provisioning engine. Can you create a new issue for your problem, ideally with a repro (e.g. a small template that on apply results in the issue) so that I can debug where it goes wrong.
Just wanted to drop some kudos to @b00johst for finding the needle in the haystack and confirm that his solution for both provisioning of new sites or fixing already damaged ones do work.
To avoid this issue again in the future, I’m also going to exclude non-custom fields from my provisioning workflow. Seems to be the only reliable solution so far.
@jansenbe
My colleague created a simple script for correcting broken ContentTypes on existing sites. The readonly field of the ContentTypes provisioned by our original templates is always false:
By looking at the original siteColumn the script updates the FieldRef with the original value for Hidden and Readonly making it possible to create pages using page templates again:
The readonly attribute of most OOB fields seems to be changed from true to false. At this point it’s only SelectFilename and LinkTitle that seems to cause any issues but I guess it’s only a matter of time before MS deploys other changes which expects the OOB fields to be left unchanged.
If I cleanup my extracted pnp template and remove all non-custom fields from the contentType and apply the template to a new site it works as expected. The OOB-field are included automatically by inheritance and this way they are not modified. Original pnp:ContentType:
Modified pnp:ContentType:
To be more specific it seems to be the following fields that cause the issue. If either of them are present in pnp:FieldRefs it will not work when using templates.
Unfortunately, this doesn’t solve any issues with existing sites. We need to create a migration script to fix our existing contentTypes.