Question

Can I set the default user in a user field to the current user -> [Me]? How is it done? The xml I already have is:

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

Solution

OTHER TIPS

Attaching event receiver could be one of the solution.

If you need that the default values are set when the new item form opens, then you need javascript/jQuery on the New Item form.

Also, even if there is no browser option for it, you can set the default value using C# code, here is what you can do for a 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-column-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-get-only-in-dispform/

Pushpendra's code only work in SharePoint 2010.

View this add-on(SharePoint Default Value Add-On), which make it possible.

Set "Current User" (User who is adding item) as default value.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top