I need a way (using code) to upload files to a SharePoint 2013 Document Library without having to go through the file drag and drop feature and I am limited to using VB script right now.
After doing some research I found code that uploads files to SharePoint along with the metadata values however I am having an issue updating a other metadata such as a choice column in SharePoint 2013 using SOAP calls through Vb script. here is the code
Const strLocalFile = "C:\temp\myLocalFile.pdf"
Const spBASE_URL = "https://thesharepointdomian/sites/yoursite/"
Const spDOC_LIB = "Your SP Doc Library Name"
Const spFILE_NAME = "NewFile.pdf"
Const spCONTENT_TYPE = "0x000000000000000000000000000000000000000"
Set ObjectStream = CreateObject("ADODB.Stream")
Set ObjectDOM = CreateObject("Microsoft.XMLDOM")
Set ObjectElement = ObjectDOM.createElement("TMP")
Set ObjectHTTP = CreateObject("Microsoft.XMLHTTP")
ObjectStream.Open
ObjectStream.Type = 1
ObjectStream.LoadFromFile (strLocalFile)
BinaryFile = ObjectStream.Read()
ObjectStream.Close
ObjectElement.DataType = "bin.base64"
ObjectElement.nodeTypedValue = BinaryFile
EncodedFile = ObjectElement.Text
strURLService = spBASE_URL + "_vti_bin/copy.asmx"
strSOAPAction = "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"
strSOAPCommand = "<?xml version='1.0' encoding='utf-8'?>"+_
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"+_
"<soap:Body>"+_
"<CopyIntoItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"+_
"<SourceUrl>" + strLocalFile + "</SourceUrl>"+_
"<DestinationUrls>"+_
"<string>" + spBASE_URL + spDOC_LIB + "/" + spFILE_NAME + "</string>"+_
"</DestinationUrls>"+_
"<Fields>"+_
"<FieldInformation Type='Text' InternalName='Title' DisplayName='Title' Value='Hello' />"+_
"<FieldInformation Type='Choice' InternalName='MyChoices' DisplayName='MyChoices' Value='AAA' />"+_
"</Fields>"+_
"<Stream>" + EncodedFile + "</Stream>"+_
"</CopyIntoItems>"+_
"</soap:Body>"+_
"</soap:Envelope>"
ObjectHTTP.Open "Get", strURLService, False
ObjectHTTP.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
ObjectHTTP.SetRequestHeader "SOAPAction", strSOAPAction
ObjectHTTP.Send strSOAPCommand
MsgBox (ObjectHTTP.responseText)
The code works in uploading the file and changing the "title" but I am having issues with the other metadata types specifically choice columns. I am new to web service calls in general and having an issue on the syntax for changing other column metadata. Can someone give me some guidance on this ?
Lets say I have a choice column named "MyChoices" set for multiple values. which has these options 'AAA", "BBB", "CCC", "DDD". How do I change the metadata information to read lets say "AAA" and "DDD". Also would help if anyone knows how to change other types like number columns and date columns.
Thanks in advance