我可以将默认用户设置为当前用户 - > [me]?怎么做? 我已经拥有的XML是:

<Field ID="{F117832D-E722-460C-A083-162C55B701F9}" Type="User" Name="PrimAdministrator" 
       DisplayName="Primary Adminstrator" Required="TRUE" UserSelectionMode="PeopleOnly" 
       ShowField="Name" ></Field>
.

有帮助吗?

解决方案

我不相信它是可能的

https://stackoverflow.com/questions/10343574/how-can-i-set-a-user-field-to-a-default-value-of-a-user-currunte-logged-in-thro

另一个选项可以是在工作流程中将其设置为

其他提示

附加事件接收器可以是解决方案之一。

如果您需要在将新项目表单打开时设置默认值,则需要在新项目表单上执行JavaScript / jQuery。 此外,即使它没有浏览器选项,也可以使用C#代码设置默认值,这是您可以为User / Group Field执行的操作:

using(SPSite site = new SPSite("site url"))
{
   SPWeb web = site.RootWeb;
   SPList list = web.Lists["My List with the field"];
   SPField fld = list.Fields["My User Or Group Field"];

   SPUser usr = web.EnsureUser("DOMAIN\\login");
   SPFieldUserValue defValue = new SPFieldUserValue();
   defValue.LookupId = usr.ID;

   fld.DefaultValue = defValue.ToString();
   fld.Update();

   list.Update();
}
.

http://social.technet.microsoft.com/forums/sharepoint/en-us/f2de4f24-21dc-452b-96c4-1da9633bfb38/ default-value-for-person-or-group-tool-in-a-sharepoint-2010-custom-list

http://kenkumar.blogspot。 In / 2011/06 / SharePoint-2010-Set-Default-Value-for.html

http://spjsblog.com/2010/05/28/get-or-set-value-for-sharepoint-field-in- newform -editform-and-dispform。 -only-In-Dismilm /

PushPendra的代码仅在SharePoint 2010中工作。

查看此加载项( sharepoint默认值附加ad-on ),这使其可能。

设置“当前用户”(添加项的用户)作为默认值。

许可以下: CC-BY-SA归因
scroll top