powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Set-PnPListItem -Batch with -UpdateType UpdateOverwriteVersion updates Modified Date

Open RRFreemanArchitect opened this issue 2 years ago • 4 comments

Reporting an Issue or Missing Feature

Set-PnPListItem updates the Modified Date when using the Batch parameter. Note: The function works correctly (retains the Modified Date) when omitting the Batch parameter.

Expected behavior

Modified Date should not change when using the UpdateOverwriteVersion UpdateType Version number stays the same

Actual behavior

Modified Date changes to the current date (incorrect behavior) Version number stays the same (correct behavior)

Steps to reproduce behavior

Requires PowerShell 7.2.3 or higher

$SiteURL = "https://prefix.sharepoint.com/sites/SiteName" $ListName= "DocumentLibraryName"

Connect-PnPOnline -Url $SiteURL -UseWebLogin

$batch = New-PnPBatch Set-PnPListItem -List $ListName -Identity 1 -Batch $batch -UpdateType UpdateOverwriteVersion -Values @{"Author"="[email protected]";"Editor"="[email protected]"} Invoke-PnPBatch -Batch $batch

What is the version of the Cmdlet module you are running?

1.10.0

Which operating system/environment are you running PnP PowerShell on?

  • [ x] Windows

RRFreemanArchitect avatar May 13 '22 19:05 RRFreemanArchitect

Hi @RRFreemanArchitect , @veronicageek - looks like this is by design.

If you dont want to update the Modified date, then use SystemUpdate

https://thesharepoint2010.wordpress.com/2012/09/26/update-systemupdate-and-updateoverwriteversion-splistitem/

gautamdsheth avatar May 16 '22 18:05 gautamdsheth

@gautamdsheth - Hmmm... I'm not sure. Because it works OK with -UpdateOverwriteVersion without the -Batch. And your article is from 2012 😅

veronicageek avatar May 16 '22 20:05 veronicageek

SystemUpdate is another option which does not allow you to change the Modified By field.
I am updating the Modified By field and must use the UpdateOverwriteVersion option which works correctly without the -Batch flag, so this is not working as designed.

RRFreemanArchitect avatar May 16 '22 21:05 RRFreemanArchitect

Issue still happening with 1.11.81

veronicageek avatar Sep 20 '22 10:09 veronicageek

@veronicageek / @RRFreemanArchitect - so maybe CSOM behavior has changed. When it comes to using batching, we always follow this behavior. Don't think it is a bug here.

image

Check from this link: https://pnp.github.io/pnpcore/using-the-sdk/listitems-intro.html#updating-list-items

gautamdsheth avatar Sep 29 '22 08:09 gautamdsheth

@gautamdsheth / @veronicageek - You may be correct that this is a bug in the CSOM call but the pnp powershell documentation does not mention the inconsistency between batch and non-batched calls Looking at the code I believe this CSOM call has the bug: item.UpdateOverwriteVersionBatch(Batch.Batch)

We need to either fix this bug (via a CSOM bug fix request) or document the bug in the documentation you referenced.

RRFreemanArchitect avatar Sep 29 '22 16:09 RRFreemanArchitect

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Dec 24 '22 02:12 github-actions[bot]

@RRFreemanArchitect - If your issue is still present, can you try with the latest nightly please. Note that if you're still on PS5 it will be 1.12.80, otherwise just run the usual which will be 2.0.x Thanks

veronicageek avatar Mar 13 '23 17:03 veronicageek

Closing as no response.

veronicageek avatar Apr 05 '23 20:04 veronicageek