Rahul Khanna

Rahul Khanna

  • NA
  • 236
  • 0

Need help in sharepoint list webmethod.

Sep 15 2012 3:30 AM
Hi all,
I have two list sourcelist and destination list both field having two common fields say for
Column A and B are common in both list. Using webservice updateListItem method I want to update field C and D in destinationlist using condition like (in destinationlist) where Field A=Field A from sourcelist and Field B=Field B from sourcelist.My question is how can I apply where condition while updating the destinationlist. Here is my code:

    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", DestinationListviewName);
    string strBatch = "<Method ID='1' Cmd='Update'>" +
    "<Field Name='ID'>1</Field>" +
    "<Field Name='FieldC'>"Somevaluefrom Source List "</Field></Method>" +
    "<Method ID='2' Cmd='Update'><Field Name='ID' >1</Field>" +
    "<Field Name='FieldD'>"Somevaluefrom Source List"</Field></Method>"; 
    elBatch.InnerXml = strBatch;
    XmlNode nreturn = ListReference.UpdateListItems("DestinationList", elBatch);

   Please somebody help me how can I apply where condition in the above code.                                       
       
Note: Using above code without where condition destitnatiolist got updated perfectly.