简体   繁体   English

无法使用 PnP 设置 Sharepoint 列查找值

[英]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.我想将文件上传到 Sharepoint 并为其中一列赋值。 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.如果该列是单行文本类型,则Add-PnPFile -Path "path\test.txt" -Folder "My Folder" -Values @{"Test Column" = "test"}之类的东西可以正常工作。

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. Powershell 没有产生错误。

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.我使用Get-PnpListItem -List "My List"来获取我要分配的项目的 ID,然后Add-PnPFile -Path "path\test.txt" -Folder "My Folder" -Values @{"Test Column" = 123}上传文件。

According to the documentation this should work but alas it doesn't.根据文档,这应该有效,但可惜它没有。 https://pnp.github.io/powershell/cmdlets/Add-PnPFile.html https://pnp.github.io/powershell/cmdlets/Add-PnPFile.html

How can I assign a value to a lookup column from powershell?如何将值分配给 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} .如果您的列名中有空格,“我的专栏”是不够的,您必须将其写为-Values @{"my_x0020_column" = 123} A space is denied as _x0020_ .空间被拒绝为_x0020_

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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