Breaking the CopySource connection within SharePoint after using CopyIntoItemsLocal

When you use the CopyIntoItemsLocal method of the Copy.asmx webservice in SharePoint, you get a copy of your document, but you also get a piece of unwelcome hidden data in the copied document – a property called “_CopySource”. Normally this is used by the “Send To” function in the SharePoint interface, and allows SharePoint to keep track of what has been copied where – then allowing “Manage Copies” functionality from the source item. That the copy webservice partially populates it looks like a bug (because the manage copies dialog is left empty), so we have to deal with it after copying.

The telltale that you have this happening is a “Go to Source” option appearing in the ECB, and permissions issues cropping up if you lock down the source library or list that you’re copying from (Sharepoint will challenge the user for a username and password when opening the copied item).

The solution is to empty the “_CopySource” property of the copied items, which you can do via the lists webservice.

Call the update items method of the lists webservice (lists.asmx), with the following SOAP header;

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/sharepoint/soap/">
  <soap:Header>
  </soap:Header>
  <soap:Body>
    <m:UpdateListItems>
      <m:listName>{Library Display Name}</m:listName>
      <m:updates>
        <Batch OnError="Continue" ListVersion="1">
          <Method ID="1" Cmd="Update">
            <Field Name="ID">{Document ID Number}</Field>
            <Field Name="MetaInfo" Property="_CopySource"></Field>
          </Method>
        </Batch>
      </m:updates>
    </m:UpdateListItems>
  </soap:Body>
</soap:Envelope>

Just replace {Library Display Name} and {Document ID Number} with appropriate data.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.