更新 SharePoint 字段链接



我使用了一段代码来检索指定内容类型的字段链接,并将该字段设置为必需或不需要。这工作正常,但是当我尝试对名称中包含空格的字段执行相同的操作时,代码会引发错误。

SPField col = //some column retrieved from a list
SPContentType ct = col.ParentList.ContentTypes["MyContentTypeName"] //gets the content type
SPFieldLink fieldLink = ct.FieldLinks["MyFieldname"]; // gets the fieldLink
ct.Update(); 

如果MyFieldName是"爱好"或"金额"之类的字符串,则它有效,但如果它是"全名"之类的字符串,则失败。

有解决方法吗?

您可能使用的是字段显示名称而不是字段内部名称

你试过吗: "Full_x0020_Name"?

最新更新