Domanda

I have migrated an old enterprise wiki site collection 2013 to SharePoint online. I did not create the source site collection, and i found that the wiki pages are associated with the built-in Enterprise Wiki Page content type and the built-in EnterpriseWiki.aspx page layout. And those 2 built components were customized by adding new site columns to them. As i know that modifying the built-in components (Content type and the Page layout) are not recommended, because the modification might get overridden by Microsoft if they apply an update. so i create a new content type which mimic the built-in one and i create a new layout which mimic the the built-in one.

But i am not sure if i can write a PnP script to update the enterprise wiki pages's Content type and Page layout without affecting the wiki pages' metadata (mainly the modified date and modified by)?

È stato utile?

Soluzione

Per my knowledge, if we change content type or page layout, the modified date and modified by will changed regardless of using PnP script or other ways.

Altri suggerimenti

If you use Set-PnPListItem to change the Content Type and/or Page Layout, as long as you use the -SystemUpdate switch parameter, it will NOT update the Modified and Editor values, for example:

Set-PNPListItem -List $yourlist -Identity $itemId2Update -Values @{"ContentTypeId"=$ct.StringId} -SystemUpdate;

That is probably the simplest and recommended approach, but alternatively, if you have "full control" permissions on the list, you can use Set-PnPListItem to change the Modified and related field value After you have made some change that caused an update. For example:

Set-PnPListItem -List $yourlist -Identity $itemId2Update -Values @{"Modified"=$NewModifiedDate;"Created"=$NewCreateDate;"Author"="some@yourtenanturl.com";"Editor"="someoneelse@yourtenanturl.com";}

Some caveats to this, first, do NOT use the -SystemUpdate parameter with this second technique, as that flag forces it to NOT update the Modified and Editor fields. Also, it seems to only work if you set all four of those values at the same time. If you want to keep the Created and Author values the same, and just change the Modified and Editor values, then set Created and Author to copies of their existing values -- if you simply leave them out, the whole thing doesn't work -- no error message, it just doesn't take affect. You will also want to save it using the UpdateOverwriteVersion method, otherwise, although the newer version will take your new values, the old version will still have your previous values.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top