powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG]Set-PnpListItem with Batch Set not working as expected

Open SP-Support opened this issue 2 years ago • 1 comments

$pnpBatch = New-PnPBatch -Connection $conn;
ForEach($item in $listItems){

        $values = @{"internalField"="UNKNOWN"}
        Set-PnPListItem -List $list -Identity $item.Id -Values $values -Connection $conn -UpdateType SystemUpdate -Batch $pnpBatch

}
Invoke-PnPBatch -Batch $pnpBatch -Connection $conn

Reporting an Issue or Missing Feature

If the interalField is a multiselect choice column the above code changing the string "UNKNOWN" into an array and posts an array of values instead of the actual string.

Expected behavior

The internalField should receive the value of "UNKNOWN" image

Actual behavior

Please describe what you see instead. Please provide samples of output or screenshots. image

Steps to reproduce behavior

See the code snippet above to reproduce.

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

2.2.0

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

  • [X] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

SP-Support avatar Nov 05 '23 20:11 SP-Support

I tried this using 2.2.23 nightly and could not reproduce. EDIT: i tried with an "allow multiple selections" version of choice field, and can reproduce: It works with Set-PnPListItem -List test -Identity 1 -Values @{someField2="UNKNOWN"} but using batch it seems like it splits the value into multiple values "U","N" etc $items | % { Set-PnPListItem -List test -Identity $_.Id -Values @{someField2="UNKNOWN"} -UpdateType SystemUpdate -Batch $pnpBatch } image

AndersRask avatar Nov 06 '23 14:11 AndersRask