Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update a document of a sharepoint list using UpdateListItems
    primarykey
    data
    text
    <p>I'm able to delete a document in a list using this piece of code:</p> <pre><code>// string fileRef = "folder/myplan.doc" private void DeleteDocument(string fileRef, string listGuid) { string strBatch = "&lt;Method ID=\"1\" Cmd=\"Delete\"&gt;" + "&lt;Field Name=\"ID\"&gt;1&lt;/Field&gt;" + "&lt;Field Name=\"FileRef\"&gt;" + fileRef + "&lt;/Field&gt;" + "&lt;/Method&gt;"; XmlDocument xmlDoc = new System.Xml.XmlDocument(); System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch"); elBatch.SetAttribute("OnError", "Continue"); elBatch.SetAttribute("ListVersion", "1"); elBatch.InnerXml = strBatch; try { XmlNode ndReturn = lists.UpdateListItems(listGuid, elBatch); } catch (Exception ex) { throw ex; } } </code></pre> <p>As you can see, i have to specify the fileRef, this will tell sharepoint which file i would want to delete.</p> <p>However, i'm not able to update the document name of a list the same way. There is no error returned, the name just doesn't get changed.</p> <p>The credentials for "lists" web service is quite correct. That's what i can guaratee. The document specified in fileRef is correct too.</p> <pre><code>private void UpdateDocument(string fileRef, string listGuid, string newName) { string strBatch = "&lt;Method ID=\"1\" Cmd=\"Update\"&gt;" + "&lt;Field Name=\"ID\"&gt;1&lt;/Field&gt;" + "&lt;Field Name=\"Title\"&gt;" + newName + "&lt;/Field&gt;" + "&lt;Field Name=\"FileRef\"&gt;" + fileRef + "&lt;/Field&gt;" + "&lt;/Method&gt;"; XmlDocument xmlDoc = new System.Xml.XmlDocument(); System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch"); elBatch.SetAttribute("OnError", "Continue"); elBatch.SetAttribute("ListVersion", "1"); elBatch.InnerXml = strBatch; try { XmlNode ndReturn = lists.UpdateListItems(listGuid, elBatch); } catch (Exception ex) { throw ex; } } </code></pre> <p>I'm curious about the examples here: <a href="http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems.aspx</a> because i don't see where to specify the document (its guid or its fileRef), both for update and delete. How sharepoint knows which document should be deleted/updated?</p> <p>I'm doing anything wrong or misunderstanding something?</p> <p>Anyone has ever been successful in updating a document please share your work. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload