2

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>

3 Answers 3

2

I don't believe it's possible

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

Another option could be to set it in a workflow

2

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/

0

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

1
  • link is dead (and iirc cost something wild like £100 anyway) Oct 14, 2015 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.