Forum Discussion
Blair24
Feb 15, 2019Copper Contributor
Set-PnPListItem - Multiple User Field
Hey Folks, Trying to update a List item via PowerShell, the column is a multiple user field. The updated users are currently in an array of Email Addresses which is causing an error. Wonderi...
Blair24
Feb 18, 2019Copper Contributor
Hi Thomas,
Yeah I've done it before, my script below is still causing an error:
$salesmangers = $ListItem.SalesManager.Email
$salesmangers += $newmanager
$newlistofmanagers = $salesmangers | Where-Object { $_ –ne $currentmanger }
$salesmangers += $newmanager
$newlistofmanagers = $salesmangers | Where-Object { $_ –ne $currentmanger }
Set-PnPListItem -List $customerlistID -Identity $ListItem.ID -Values @{"SalesManager" = $newlistofmanagers}
Thomas Berman
Feb 18, 2019Iron Contributor
What error are you getting and where is it failing?
Also, to access that field, try $salesmangers = $ListItem.FieldValues.SalesManager.Email
- Blair24Feb 19, 2019Copper Contributor
Error is:
Set-PnPListItem : The specified user could not be found.
Line:
Set-PnPListItem -List $customerlistID -Identity $ListItem.ID -Values @{"SalesManager" = $newlistofmanagers}
Swapping to FieldValues.SalesManager.Email made no difference either.
- Thomas BermanFeb 19, 2019Iron Contributor
Try checking your $newlistofmanagers before passing it into Set-PnPListItem, and check $newmanager to make sure they look right.
Something must be going wrong somewhere along the line of building that array, since an array of valid email addresses will work with that cmdlet no problem.
- Blair24Feb 20, 2019Copper Contributor
Checked the array, but looks fine with valid email addresses.
$newlistofmanagers.GetType() also returns as an array as well so not sure what's happening!