I have SP Foundation without access to the server local folders, so my only change is through Sharepoint designer as far as I know. how can I copy a List item attachment to document library with SharePoint Designer workflows? Note. The document library does not have the same fields as the list.
1 Answer
I could not achieve my goal to copy a list attachment to a document library but on my investigation I discovered how to copy files from one document library to another with Sharepoint service copy.asmx and sharepoint services (see more information on http://spservices.codeplex.com/)
I post below the different functions I created for my testing, as I said they work but not for list attachments as a source.
uploadFile uses soap CopyIntoItemsLocal to upload.
uploadFile2 uses SPServices jquery with CopyIntoItemsLocal
uploadFile3 uses SPServices jquery with CopyIntoItems
Note. I post this because my research didn't help me on my goal but might help someone else.
function uploadFile(source,destination) { //source = encodeURI(source); //destination = encodeURI(destination); var soapEnv = ""+ ""+ ""+ "" + source + ""+ ""+ "" + destination + ""+ ""+ ""+ ""+ ""; $.ajax({ url: "http://sharepoint.cplis.com/test/CentralisTest/_vti_bin/copy.asmx", beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItemsLocal"); }, type: "POST", dataType: "xml", data: soapEnv, complete: processResult, contentType: "text/xml; charset=\"utf-8\"" }); } function processResult(xData, status) { alert("Uploaded SuccessFully"); } function uploadFile2(source,destination) { //source = encodeURI(source); //destination = encodeURI(destination); $().SPServices({ operation: "CopyIntoItemsLocal", async: false, SourceUrl: source, DestinationUrls: [destination], completefunc: function(xData, Status) { alert("Status=" + Status + " XML=" + xData.responseXML.xml); } }); } function getStream(source) { var myStream = ""; //source = encodeURI(source); jQuery().SPServices({ operation: "GetItem", async: false, Url: source, completefunc: function(xData, Status) { myStream = jQuery(xData.responseXML).find("Stream").text(); //MSDN: base-64 representation of the retrieved document's binary data. alert("myStream: " + myStream); } // end completefunc }); // end getItem } function uploadFile3(source, destination, myStream) { source = encodeURI(source); //destination = encodeURI(destination); jQuery().SPServices({ operation: "CopyIntoItems", async: false, SourceUrl: source, DestinationUrls: [destination], Stream: myStream, //whatever variable you used to store the base64 encoded binary data from the GetItem call completefunc: function(xData, Status) { alert("Status=" + Status + "\n" + xData.responseText); } // end completefunc }); // end CopyIntoItems }
Have fun!!