Sharepoint 2010 查找字段 ID 格式

发布于 2024-12-11 14:17:05 字数 1601 浏览 0 评论 0 原文

我是 Sharepoint 2010 的新手,目前正在尝试创建查找字段,将其添加到内容类型并通过 Visual Studio 2010 SharePoint 项目将其添加到列表中。但我遇到一些奇怪的问题。

我通过以下方式定义了一个查找字段:

  <Field ID="{2A5567B7-1175-4E26-A4ED-382E4744D17A}" Type="Lookup" Name="SomeLookupField" List="Lists/SomeList" ShowField="ItemName" DisplayName="Some Field" Group="Custom Group" ReadOnly="TRUE" />

然后我通过 FieldRef 元素将其添加到 ContentType 中。最后,列表定义在 Schema.xml 中包含相同的元素,

它工作正常,直到我尝试将我的网站保存为模板。 Sharepoint 无法导出站点并显示错误:

Microsoft.SharePoint.SPException:导出名为“SomeLookupField”的网站字段时出错。在 Microsoft.SharePoint.SPSolutionExporter.ExportFields(SPFieldCollection 字段,字符串分区名称)

这是由错误引起的:

SPSolutionExporter:System.FormatException:Guid 应包含 32 位数字和 4 个破折号 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。在 System.Guid..ctor(String g) 在 Microsoft.SharePoint.SPSolutionExporter.GetFieldSchemaXml(SPField 字段、SPWeb web、布尔值 isFieldFromWeb、布尔值removeSealedAttribute) 在 Microsoft.SharePoint.SPSolutionExporter.ExportField(SPField 字段、SPWeb web)

在 Microsoft.SharePoint.SPSolutionExporter.GetFieldSchemaXml(SPField field, SPWeb web, Boolean isFieldFromWeb, Boolean 发现查找字段 ID 不应包含大括号,如下所示:

<Field ID="2A5567B7-1175-4E26-A4ED-382E4744D17A"

在我更改它之后,导出开始正常工作。但从 Visual Studio 重新部署现在已被破坏,因为它在删除旧功能时不会删除该字段,并且在更新功能激活时失败并出现错误:

部署步骤“激活功能”中出现错误:在当前网站集中找到了功能 {235313d2-4091-4655-8b35-70b3ad31b9f4} 中定义的 ID 为 {2A5567B7-1175-4E26-A4ED-382E4744D17A} 的字段,或者在子网站中。

我想知道我的查找字段定义有什么问题?定义查找字段的有效格式是什么?

I'm new to Sharepoint 2010 and I'm currently trying to create lookup field, add it to content type and add it to the list via Visual Studio 2010 SharePoint project. But I experience some weird problem.

I've defined a lookup field in the following way:

  <Field ID="{2A5567B7-1175-4E26-A4ED-382E4744D17A}" Type="Lookup" Name="SomeLookupField" List="Lists/SomeList" ShowField="ItemName" DisplayName="Some Field" Group="Custom Group" ReadOnly="TRUE" />

Then I added it to ContentType via FieldRef element. And, finally, List Definition contains the same element in Schema.xml

It works fine until I'm trying to save my site as template. Sharepoint fails to export the site and displays error:

Microsoft.SharePoint.SPException: Error exporting the site field named "SomeLookupField". at Microsoft.SharePoint.SPSolutionExporter.ExportFields(SPFieldCollection fields, String partitionName)

That is caused by the error:

SPSolutionExporter: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). at System.Guid..ctor(String g) at Microsoft.SharePoint.SPSolutionExporter.GetFieldSchemaXml(SPField field, SPWeb web, Boolean isFieldFromWeb, Boolean removeSealedAttribute) at Microsoft.SharePoint.SPSolutionExporter.ExportField(SPField field, SPWeb web)

Playing around I found out that lookup field ID should not contain curly brackets and be like the following:

<Field ID="2A5567B7-1175-4E26-A4ED-382E4744D17A"

After I changed it export start working fine. But redeploy from Visual Studio is broken now as it doesn't delete the field while removing old feature and fails on updated feature activation with the error:

Error occurred in deployment step 'Activate Features': The field with Id {2A5567B7-1175-4E26-A4ED-382E4744D17A} defined in feature {235313d2-4091-4655-8b35-70b3ad31b9f4} was found in the current site collection or in a subsite.

I wonder what can be wrong with my lookup field definition? What is a valid format of defining lookup fields?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音盲 2024-12-18 14:17:05

找到了解决方案。查找列定义必须将覆盖属性设置为“TRUE”。关于它的博客 此处

Found the solution. Lookup column definition must have overwrite attribute set to 'TRUE'. Blogged about it here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文