如何在 Sharepoint 2010 中将用户字段设置为当前通过 XML 登录的用户的默认值? [英] How can I set a User field to a default value of a user currently logged in through XML in Sharepoint 2010?
问题描述
我正在尝试在 XML 中为用户类型的字段创建字段定义,并且需要将其默认值设置为当前登录的用户.我该怎么做?
I'm trying to create an field definition in XML for a field of a User type and need to set its default value to a user currently logged in. How do I do that?
非常感谢.
推荐答案
这是我最近的一次:
<Field ID="{99ced9dc-5715-47a7-9ede-1733f027eeb4}"
Name="MyField"
DisplayName="My Field"
Type="User"
List="UserInfo"
UserSelectionMode="PeopleOnly"
Required="TRUE">
<DefaultFormula>=";#"&Me</DefaultFormula>
</Field>
它不会爆炸,但它也没有给出预期的结果.问题是 Me
会给出用户的名字,但由于 用户字段 是一种特殊类型的 查找字段,名称被忽略.所需要的只是 ID,但我找不到任何能给我带来价值的东西.
It doesn't blow up, but it doesn't give the desired result either. The problem is that Me
will give the name of the user, but since the User Field is a special type of Lookup Field, the name is ignored. All that is needed is the ID, but I haven't been able to find anything that will give me that value.
以下是一些可能的解决方法:
Here are some possible workarounds:
- 自定义字段:当前用户作为 SharePoint 个人或组字段的默认值
- 事件接收器:添加当前用户到个人字段默认值与事件接收器 ItemAdding–SharePoint
- Javascript:当前用户为默认值SharePoint 人员或组字段的值
这篇关于如何在 Sharepoint 2010 中将用户字段设置为当前通过 XML 登录的用户的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!