如何更新“标题”的默认值 “文档”字段 内容类型或从其继承的类型

发布于 2024-07-10 03:54:11 字数 341 浏览 8 评论 0原文

“标题”字段被密封。 任何更新默认值的尝试都会将该值重置回“null”,


感谢您的宝贵时间。

您执行“RemoveFieldRef 和 FieldRef 立即返回”的想法与通过“文档”或继承的内容类型的界面设置属性“必需”和“默认值”相同,尽管如果我们正在构建,您的想法会有所帮助自定义内容类型。

将“标题”设置为必需并不在所有情况下都有效。 其中一种情况是当您尝试通过“新建”添加项目时(在我的例子中,它会打开一个基于 Office 2007 的模板)。

由于“标题”作为必填字段给我带来了困难,我想尝试“默认值”路线,但即使这个路线似乎也不起作用。 有什么帮助吗?

"Title" field is sealed. Any attempts to update the default value resets the value back to "null"


Thanks for your time.

Your idea of doing "RemoveFieldRef and FieldRef it right back in" would be the same as setting the properties "Required" and "Default Value" through the interface for the "Document" or inherited content types though your idea would help if we are building custom content types.

Setting "Title" to required does not work in all situations. One such situation is when you try to add a item through "New" (which in my case opens up a template based on office 2007).

Since "Title" as required field was giving me hard time, I wanted to try the "DefaultValue" route but even this one does not seem to work. Any help?

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

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

发布评论

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

评论(5

葬﹪忆之殇 2024-07-17 03:54:11

您可以将RemoveFieldRef 和FieldRef 立即返回。事实上,文档内容类型本身会执行此操作以使标题不再是必需的。 在默认的 ctypeswss.xml 中,文档内容类型没有设置密封属性。

查看 [12]\TEMPLATE\FEATURES\CTypes\ctypeswss.xml 并向下滚动到第 32 行左右,查看内容类型如何执行此操作。

.b

(免责声明:我正在发高烧,所以如果我没有任何意义,请责怪我厨房里跑来跑去的棒棒糖)

You can RemoveFieldRef and FieldRef it right back in. In fact, the document content type does this itself to make the title not required. In the default ctypeswss.xml there is no sealed attribute set on the Document content type.

Check out [12]\TEMPLATE\FEATURES\CTypes\ctypeswss.xml and scroll down to about line 32 to see how the content type does this.

.b

(Disclaimer: I am running a high fever, so if I don't make any sense, blame the lollipops running around my kitchen)

倾城泪 2024-07-17 03:54:11

使用您向“已添加项目”和“已更新项目”事件的内容类型注册的事件接收器执行此操作。 这样,每当添加新项目时,都可以为其指定默认标题。 您可以在内容类型 CAML 中注册事件接收器,如下所示:

  <ContentType ...>
    <FieldRefs>
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="My Title" Required="FALSE" ShowInDisplayForm="FALSE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE"/>
    </FieldRefs>
    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
        <Receivers>
          <Receiver>
            <Name>TitleCreator</Name>
            <Type>ItemAdded</Type>
            <Assembly>...</Assembly>
            <Class>TitleCreatorItemEventReceiver</Class>
          </Receiver>
          <Receiver>
            <Name>TitleCreator</Name>
            <Type>ItemUpdated</Type>
            <SequenceNumber>1</SequenceNumber>
            <Assembly>...</Assembly>
            <Class>TitleCreatorItemEventReceiver</Class>
          </Receiver>
        </Receivers>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>

Do this with a Event Reciever that you register with the Content Type for Items Added and Items Updated Events. This way whenever a new Item is added it can be given your default Title. You can register Event Recievers in the Content Type CAML like such:

  <ContentType ...>
    <FieldRefs>
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="My Title" Required="FALSE" ShowInDisplayForm="FALSE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE"/>
    </FieldRefs>
    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
        <Receivers>
          <Receiver>
            <Name>TitleCreator</Name>
            <Type>ItemAdded</Type>
            <Assembly>...</Assembly>
            <Class>TitleCreatorItemEventReceiver</Class>
          </Receiver>
          <Receiver>
            <Name>TitleCreator</Name>
            <Type>ItemUpdated</Type>
            <SequenceNumber>1</SequenceNumber>
            <Assembly>...</Assembly>
            <Class>TitleCreatorItemEventReceiver</Class>
          </Receiver>
        </Receivers>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>
等风来 2024-07-17 03:54:11

这是我们对“Title”的发现:

  • “Title”字段未在 fieldwss.xml 中密封
    (12\TEMPLATE\FEATURES\fields)
  • 它没有密封在 ctypeswss.xml 中的“文档”内容类型下
    (12\TEMPLATE\FEATURES\ctypes)
  • 它被密封在 schema.xml 中的文档库定义中
    (12\TEMPLATE\FEATURES\DocumentLibrary\DocLib)

通过 OM 设置默认值会在内容类型 .Update() 上将该值重置为 NULL。 这是因为“标题”被封装在 DL 定义中。

向 MS 提出服务请求。 等待结果!!!

This is what we have found for "Title":

  • The “Title” field is not sealed in fieldwss.xml
    (12\TEMPLATE\FEATURES\fields)
  • It’s not sealed under “Document” content type in ctypeswss.xml
    (12\TEMPLATE\FEATURES\ctypes)
  • It is sealed in Document library definition in the schema.xml
    (12\TEMPLATE\FEATURES\DocumentLibrary\DocLib)

Setting default value through OM would reset the value to NULL on content type .Update(). This is because "Title" is sealed in the DL definition.

Opened a service request with MS. Waiting for the results!!!

薔薇婲 2024-07-17 03:54:11

嗯...如果您不执行自定义内容类型,那么我建议您通过功能接收器执行您想要的操作。 您可以将该接收器附加到默认文档内容类型并根据需要处理您的列,例如设置默认值或仅在未提供用户值的情况下设置默认值。

.b

Hm... If you are not doing custom content types then I would suggest doing what you want through a feature receiver. You can attach that receiver to the default document content type and handler your columns as you like, for example setting default values or only setting default values if no user value has been provided.

.b

江挽川 2024-07-17 03:54:11

这种方法适用于除隐藏的“标题”字段之外的所有字段,该字段似乎非常特别

This approach works for all fields except for hidden "Title" field which seems to really special

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