How to modify the custom People/Groups type column of a SharePoint List using Lists.ASMX

SharePoint has more than ten out-of-the-box webservices which will provide lots of functionalities that we want. Lists.asmx is one of such SharePoint webservice that help us to do certain operations with SharePoint lists. We can locate that webservice physically in the following location. 

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\isapi

Now we can come to our requirment. If you want to update any column values in SharePoint lists we can consume Lists.asmx to accomplish that requirment. Below, I am giving a sample code snippet for updating the custom People/Groups type column values of a SharePoint list.

/******** Code snippet for modifying the custom People/Groups type column of a SharePoint List using Lists.ASMX*******/

/******** Written in ASP.NET Application **********/

protected void Button1_Click(object sender, EventArgs e)

    {

        /*Declare and initialize a variable for the Lists Web service.*/

        ListService.Lists oListService = new ListService.Lists();

        /*Authenticate the current user by passing their default

        credentials to the Web service from the system credential cache.*/

        oListService.Credentials =

            System.Net.CredentialCache.DefaultCredentials;

        /*Set the Url property of the service for the path to a subsite.*/

        oListService.Url =

            "https://<site%20name>/_vti_bin/Lists.asmx";

        /*Create an XmlDocument object and construct a Batch element and its attributes. Note that an empty ViewName parameter causes the method to use the default view. */

        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

        System.Xml.XmlElement batchElement = doc.CreateElement("Batch");

        batchElement.SetAttribute("OnError", "Continue");

        batchElement.SetAttribute("ListVersion", "1");

        batchElement.SetAttribute("ViewName", "");

       

        /*Specify methods for the batch post using CAML. In each method

        include the ID of the item to update and the value to place in the

        specified column.*/

        batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +

            "<Field Name='ID'>9</Field>" +

            "<Field Name='Title' Type='Text'>vvvv</Field>" +

             "<Field Name='Author' Type='User' frombasetype='FALSE'>14;#Sowmyan Soman</Field>" + // this column couldn’t update through webservice if you want to know how we can do that please refer here

              "<Field Name='Users' Type='User' frombasetype='FALSE'>14;# Sowmyan Soman</Field>" +

            "</Method>";

        XmlNode oNode = oListService.UpdateListItems("Shared Documents", batchElement);

        Response.Write(oNode.OuterXml);

    }