UpdateListItems Web Service with VBScript filterin

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
ismailc
Posts: 37
Joined: Mon Nov 09, 2009 6:11 pm

UpdateListItems Web Service with VBScript filterin

Post by ismailc »

Hi All, Help please

I managed to update the list with VBSCRIPT, I have 1 issue

I only seem to update the list when filtering on ID, I don't have the id & only know the Title in my 3rd party app. I removed ID & tried filtering on Title only but not luck

Code: Select all

'some vars
url = "http://srv08-za143/workspace/departments/masterfiles/_vti_bin/Lists.asmx"
list = "Vendor Request"
id = 2
title = "test"

'the caml
batch = "<Batch OnError='Continue' ListVersion='1'>"
'batch = "<Batch OnError='Continue' PreCalc='TRUE' ListVersion='0'>"
batch = batch + " <Method ID='1' Cmd='Update'>"
batch = batch + "  <Field Name='ID'>211</Field>"
batch = batch + "  <Field Name='FSObjType'>1</Field>"
batch = batch + "  <Field Name='BaseName'>Test</Field>"
batch = batch + "  <Field Name='Title'>Test</Field>"
batch = batch + "  <Field Name='Vendor0'>Test</Field>"
batch = batch + " </Method>"
batch = batch + "</Batch>"

'soap wrapper plus some info in body
request =  "<?xml version='1.0' encoding='utf-8'?>"
request =  request + "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
request =  request + "            xmlns:xsd='http://www.w3.org/2001/XMLSchema'"
request =  request + "            xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
request =  request + "  <soap:Body>"
request =  request + "  <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"
request =  request + "              <listName>" & list & "</listName>"
request =  request + "              <updates>" & batch & "</updates>"
request =  request + "  </UpdateListItems>"
request =  request + "  </soap:Body>"
request =  request + "</soap:Envelope>"

'post it up and look at the response
with CreateObject("Microsoft.XMLHTTP")
 .open "POST", url, False , null, null
 .setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
 .setRequestHeader "SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"
 .send request
 wscript.echo .responseText 
end with

Please Assist! - nearly there

User avatar
ismailc
Posts: 37
Joined: Mon Nov 09, 2009 6:11 pm

UpdateListItems Web Service with VBScript filterin

Post by ismailc »

Thank You All helping me all through Last week. Especially JvierraI know I have been a pest but so happy now that i got it going:I found to update existING List without id should leave ID blankbatch = batch + " <Method ID='1' Cmd='Update'>"batch = batch + " <Field Name='ID'></Field>"batch = batch + " <Field Name='FSObjType'>1</Field>"batch = batch + " <Field Name='BaseName'>Test</Field>"batch = batch + " <Field Name='Title'>Test</Field>"batch = batch + " <Field Name='Vendor0'>Test2New</Field>"batch = batch + " <Field Name='Site0'>Test2like</Field>"batch = batch + " </Method>"batch = batch + "</Batch>"

Locked