向 sharepoint 中的内容类型添加查找字段 [英] Add a lookup field to a content type in sharepoint

查看:21
本文介绍了向 sharepoint 中的内容类型添加查找字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 xml 定义向 sharepoint 中的内容类型添加查找字段?(我遇到了错误).

How can I add a lookup field to a content type in sharepoint using the xml definition? (I'm getting errors).

注意事项:- 将内容类型添加到文档库时,查找列表将存在.- 查找列表将始终具有相同的名称.- 查找列表的名称中有一个空格.

Things to note: - The lookup list will exist when the content type is added to the document library. - The lookup list will always have the same name. - The lookup list has a space in the name.

这是我添加到 xml 中的内容:

This is what I've added to the xml:

  <Field ID="{GUID}"
         Type="Lookup"
         List="$Resources:core,lists_Folder;/List%20Name"
         ShowField="Title"
         Name="MyLookupFieldName"
         DisplayName="MyLookupFieldName"
         StaticName="MyLookupFieldName"
         Hidden="FALSE"
         Required="FALSE"
         Sealed="TRUE"
         >

然后当我以编程方式将内容类型添加到文档库时,我收到一个异常(没有有​​用的信息),并且以下内容会记录到共享点日志中:

When I then programatically add the content type to a document library I get an exception (with no useful information), and the following is logged to the sharepoint log:

08/18/2009 17:13:39.50 w3wp.exe (0x08B8) 0x11B0 Windows SharePoint Services 数据库 6f8g 意外 意外查询执行失败,错误代码 8114.下面包含来自 SQL Server 的其他错误信息.将数据类型 nvarchar 转换为 uniqueidentifier 时出错."查询文本(如果可用):{?=call proc_GetListMetaDataAndEventReceivers(?,?,?,?,?,?)}"

08/18/2009 17:13:39.50 w3wp.exe (0x08B8) 0x11B0 Windows SharePoint Services Database 6f8g Unexpected Unexpected query execution failure, error code 8114. Additional error information from SQL Server is included below. "Error converting data type nvarchar to uniqueidentifier." Query text (if available): "{?=call proc_GetListMetaDataAndEventReceivers(?,?,?,?,?,?)}"

推荐答案

幸运的是,在 SharePoint 2010 中,您可以通过设置所有必需的属性以声明方式执行此操作,如下面的工作示例所示.

Luckily, in SharePoint 2010, you can declaratively do this by setting all required properities as shown in the following working example.

<Field Type="Lookup" DisplayName="Link Type" Description="Represents link type." 
Required="TRUE" EnforceUniqueValues="FALSE" List="Lists/Links Types" WebId="~sitecollection" 
Overwrite="TRUE" PrependId="TRUE" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE" 
Group="Research Links Columns" ID="{a15e9fa2-4ea0-41f1-a583-b21d53cf72d3}" 
SourceID="{30650f6f-fbb8-4acc-a935-29745f5d3c59}" StaticName="Link_x0020_Type" 
Name="Link_x0020_Type" Hidden="FALSE" ReadOnly="FALSE"></Field>

将 WebId 设置为~sitecollection"的值并将 Overwrite 设置为 TRUE 很重要.
更多信息

It's important to set WebId to have value of "~sitecollection" and set Overwrite to be TRUE.
More info

这篇关于向 sharepoint 中的内容类型添加查找字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆