[BUG] - Set-PnPListItem not writing all values for Multiple User fields #3754
Replies: 8 comments
-
hi @simoncumming , can't reproduce the issue. Is it possible that one of the users that you specified in the array is not added to User Site Information list ? If that's the case, then you need to "add" them to the site using |
Beta Was this translation helpful? Give feedback.
-
Hi @gautamdsheth can confirm that I've added all the users via New-PnPUser (should have included that in the sample script sorry). I've also verified this by swapping the order:
` Email : AdeleV@v5wpc.onmicrosoft.com Email : DiegoS@v5wpc.onmicrosoft.com With the user values order changed:
RETURNS: ` Email : AdeleV@v5wpc.onmicrosoft.com Email : GradyA@v5wpc.onmicrosoft.com I am also having this issue across multiple tenants. The prompt for me to check this was I found this forum post from someone in 2020 that was experiencing a similar issue https://techcommunity.microsoft.com/t5/sharepoint-developer/add-pnplistitem-and-set-pnplistitem-multiple-user-field-adding/m-p/1962678/highlight/true#M9770 I searched for an issue for it but couldn't find that they'd ever logged one. |
Beta Was this translation helpful? Give feedback.
-
Nope, still can't repro: ![]() and ![]() @veronicageek - can you maybe try reproducing this issue ? |
Beta Was this translation helpful? Give feedback.
-
I cannot reproduce either (using 2.3.0) |
Beta Was this translation helpful? Give feedback.
-
@gautamdsheth @veronicageek thanks for both looking into this, do you have any clues what could potentially cause something like this? Are there any settings or dependencies or something I should be looking at? Just trying to figure out the next troubleshooting steps |
Beta Was this translation helpful? Give feedback.
-
Am not sure about this. But looks like it could be an issue with users itself. Not sure how we can help here, am moving this to a discussion , maybe somebody in the community has some idea. Don't see this as bug with the module itself. |
Beta Was this translation helpful? Give feedback.
-
I just had the same problem. PS D:\PowershellSkripte\Code> $siteData.Administratoren.GetType() PS D:\PowershellSkripte\Code> [string[]]$sa = $siteData.Administratoren Set-PnPListItem -List "SharePointSiteAdmins" -Identity $spListItem.ID -Values @{"Title" = $siteData.Title; "SiteID" = $siteData.SiteID; "SiteAdmins" = $sa; "SiteDescription" = $siteData.Description } -ErrorAction Stop |
Beta Was this translation helpful? Give feedback.
-
I've run into this same issue with a client. I've tried @st1234b's solution but still doesnt work [string[]]$adminUsers = "Name1@XX.com","Name2@XX.com" Just isolating on this one field seems to update the field with the first name in the array. Not sure why it isn't updating two. The script runs successfully with no errors but I can see the value isnt updated. Anyone else have this issue? Just updated my module and tried again with the same result UPDATE: [string[]]$adminUsers = "Name1@XX.com","Name2@XX.com","Name3@XX.com" Results in an update The column now has "Name1@XX.com","Name3@XX.com" This is thanks to https://techcommunity.microsoft.com/discussions/sharepointdev/add-pnplistitem-and-set-pnplistitem-multiple-user-field---adding-more-than-one-s/1961918 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Reporting an Issue or Missing Feature
When running set-pnplistitem and trying to set the value for a User type field to 3 users, it will add only users #1 and #3. If trying to add 2 users, it will add only user #1
Expected behavior
When adding 3 values for a user field, I expected all 3 values to be populated for the item.
Actual behavior
When adding 3 values, I see values #1 and #3 added to the item, but not value #2
Steps to reproduce behavior
Behaviour can be reproduced with a script similar to this:
set-pnplistitem -List $ListName -Identity $id -Values @{"DocumentAuthor" = "AdeleV@v5wpc.onmicrosoft.com","GradyA@v5wpc.onmicrosoft.com","diegos@v5wpc.onmicrosoft.com"} $item = Get-PnPListItem -List $ListName -Id $id $item.FieldValues.DocumentAuthor
The syntax of this is directly from: https://pnp.github.io/powershell/cmdlets/Set-PnPListItem.html#-values
What is the version of the Cmdlet module you are running?
running version 2.3.0
Which operating system/environment are you running PnP PowerShell on?
Beta Was this translation helpful? Give feedback.
All reactions