简体   繁体   中英

Unable to set Sharepoint column lookup value using PnP

I want to upload a file to Sharepoint and assign a value to one of the columns. Something like Add-PnPFile -Path "path\test.txt" -Folder "My Folder" -Values @{"Test Column" = "test"} works fine if the column is of a single line text type.

However, if the column is a lookup column it does not work. My file gets uploaded but the field is not populated. Powershell generates no error.

I used Get-PnpListItem -List "My List" to get the ID of the item I want to assign and then Add-PnPFile -Path "path\test.txt" -Folder "My Folder" -Values @{"Test Column" = 123} to upload the file.

According to the documentation this should work but alas it doesn't. https://pnp.github.io/powershell/cmdlets/Add-PnPFile.html

How can I assign a value to a lookup column from powershell?

Found the answer myself. If you have a space in your column name, "my column" is not sufficient, instead you have to write it out as -Values @{"my_x0020_column" = 123} . A space is denied as _x0020_ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM