Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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" ?> 
<Batch>
  <Method ID="1" Cmd="New">
    <Field Name="Employee" >Jimbo Alba</Field>
  </Method>
</Batch>

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

1 Answer 1

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... 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

 
discard

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.