Forum Discussion
Brent Ellis
Mar 07, 2017Silver Contributor
PnP PowerShell Set-PnPListItem : Save Conflict.
So I am learning PnP PowerShell, and a simple use case of iterating a list and updating fields on each list item based on other fields
I am frequently getting a "Save Conflict Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes."
This is updating 3 fields on a list item, and there are SPD workflows associated with the items (on change).
Is the Set-PnPListItem updating all of the values at once, or making 3 separate changes? I've never had an issue doing this with regular non-PnP scripts, and I dont really understand where the conflict is coming from.
Get-PnpListItem -List "My List" -PageSize 25 | % { if($_.FieldValues.CustomerID -ne $_.FieldValues.Customer_x003a__x0020_DISPLAY_ID -or $_.FieldValues.LegacyID -ne $_.FieldValues.Customer_x003a__x0020_LEGACY_ID){ Write-Host "Updating" -ForegroundColor Red $metadata = @{} $metadata.Add("ForceUpdate","99999") $metadata.Add("CustomerID","$($_.FieldValues.Customer_x003a__x0020_DISPLAY_ID)") $metadata.Add("LegacyID","$($_.FieldValues.Customer_x003a__x0020_LEGACY_ID)") Set-PnPListItem -List "My List" -Identity $_.Id -Values $metadata } }
- According to the code, Set-PnPListItem
https://github.com/SharePoint/PnP-PowerShell/blob/master/Commands/Lists/SetListItem.cs
does only one ExecuteQuery for each item (including all the fields). I'd suggest that you try same code with another list without workflows associated to the "on change".