0
Reply

Please somebody help me how do i pass custom field as parameter while updating list using webservice

Ask a question
Rahul Khanna

Rahul Khanna

12y
1.1k
1
Hi all,


I have a custom list called projectlist. I want to update this list with some value thru webservice based on condition, like update projectlist column say project completedDate where projectname="Sharepoint" and Status="Completed". 


To update this list I have used the following technique which I got from msdn site:


System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.SetAttribute("ListVersion", "1");
elBatch.SetAttribute("ViewName", projectlistviewName);


string strBatch = "<Method ID='1' Cmd='Update'>" +
"<Field Name='ID'>" +RowID + "</Field>" +
"<Field Name='ProjectCompletedDate'>ProjectCompletionDatevalue</Field></Method>" +
"<Method ID='1' Cmd='Update'><Field Name='ID' >" +RowID + "</Field>" +
"<Field Name='ProjectDescription'>"Project Description Value"</Field></Method>"; 


elBatch.InnerXml = strBatch;
XmlNode nreturn = ListReference.UpdateListItems("projectlist", elBatch);


The above method works perfectly if we want to update the list item based on RoWId, but if want to update the list item based on custom field like projectname or Status field(if we replace the ID field with any custom field), I am getting this error:


"The URL provided contains an invalid Command or Value. Please check the URL again."


Please...please...sombody help me out, my objective is to update the list item where projectname="Sharepoint" and Status="Completed".