title: Add a new list item with a Person or Group field
body: <p>I have a DataTable, and I want to add new items to a Sharepoint list using the data in the table's DataRows.  But I'm having trouble adding data for a field where the type is "Person or Group", because this field seems to require an ID, not just "lastname, firstname".  I made a class to build the CAML for a call to <code>UpdateListItems()</code>, which works fine for adding any other type of data to the list:</p>
  
  <pre><code>public class CAMLBuilder
  {
      List&lt;string&gt; nameFields;
  
      public CAMLBuilder()
      {
          nameFields = new List&lt;string&gt;();
          nameFields.Add("Requestor");
      }
  
      public XmlElement batchAddElement(DataTable addTable)
      {
          XmlDocument doc = new XmlDocument();
          XmlElement element = doc.CreateElement("Batch");
          element.SetAttribute("OnError", "Continue");
          element.SetAttribute("ListVersion", "1");
          element.SetAttribute("ViewName", "");
          int methodCtr = 1;
          string batchStr = "";
          foreach (DataRow dr in addTable.Rows)
          {
              batchStr += "&lt;Method ID='" + methodCtr + "' Cmd='New'&gt;";
              foreach (DataColumn dc in addTable.Columns)
              {
                  batchStr+="&lt;Field Name='"+dc.ColumnName+"'&gt;" + convertName(dc.ColumnName,Convert.ToString(dr[dc])) + "&lt;/Field&gt;";
              }
              batchStr+="&lt;/Method&gt;";
              methodCtr++;
          }
          element.InnerXml = batchStr;
          return element;
      }
  
      private string convertName(string columnName,string name)
      {
          if (nameFields.Contains(columnName))
          {
              name = "-1;#" + name;
          }
          return name;
  
      }
  
  }
  </code></pre>
  
  <p>The <code>"-1;#"</code> in <code>convertName()</code> is something that I saw in <a href="http://spservices.codeplex.com/discussions/277482" rel="nofollow">this discussion</a> as a workaround that lets you avoid looking up the person's ID.  But it doesn't work; I get this error message in my returned XML:</p>
  
  <pre><code>0x81020054The user does not exist or is not unique.
  </code></pre>
  
  <p>Is there a way to build the CAML so that I don't need the ID and can just use the name?</p>