SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a CAML batch file to add items to a list using SharePoint List Web Service on my InfoPath form.

The batch file is like this:

<?xml version="1.0" encoding="UTF-8" ?> 
  <Method ID="1" Cmd="New">
    <Field Name="Employee" >Jimbo Alba</Field>

It also works for "Person or Group" field types.

   <Field Name="Person" >1</Field>

That is if you know that the person's ID in the User Information List is 1. In case the person is not yet in the User Information List how can I add it using InfoPath or through code?

share|improve this question
up vote 3 down vote accepted

You can add user to a SharePoint portal using SPWeb.EnsureUser method. This way he will be also added to the User Information List.

The example of usage:

SPList userInformationList = SPContext.Current.Web.SiteUserInfoList; 
SPUser user = SPContext.Current.Web.EnsureUser(@"DOMAIN\username"); 
SPListItem userItem = userInformationList.Items.GetItemById(user.ID);
// do whatever you need with userItem or with user.ID
share|improve this answer
Very promising answer from you @omlin. I'll post back after I try it. – Jimbo Alba Sep 16 '11 at 10:37
thanks for the help @omlin. it works! – Jimbo Alba Sep 21 '11 at 16:06
you're welcome! and dare to mention, that here at SharePoint StackExchange, people thank through upvoting and accepting the question as the right solution :) – Andrey Markeev Sep 21 '11 at 17:55
@omlin - Do you know if this is possible with SharePoint ADO.NET Data Services? I have been struggling to figure out how to do something similar from a client machine (not running on the server). – Pandincus Nov 21 '11 at 1:34
@Pandincus - you'd better use SharePoint Client Object Model. It has almost same objects, for example, Web object has SiteUserInfoList property, and so on...… If this information will not help, I recommend you to create a new separated question. – Andrey Markeev Nov 21 '11 at 8:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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