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?


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
  • Very promising answer from you @omlin. I'll post back after I try it. – Jimbo Alba Sep 16 '11 at 10:37
  • 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... msdn.microsoft.com/en-us/library/… 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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