0

I have small list inside SharePoint 2010 site.

This list contains following columns:

enter image description here

I also created script which is able to Web Services to add new item or perform update.

What I know, the update may be performed only based on ID field, but the problem is that instead of ID, I would like to use CaseNumber# field.

So if CaseNumber# is 12345678 then update record 1

This is portion of my code:

Option Explicit

Dim sharePointURL, listName, batch, response, request, oXmlHTTP, domainName, domainUserName, domainPassword

domainName = "domainname"
domainUserName = "username"
domainPassword = "password"

set oXmlHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")

sharePointURL = "http://sharepointsite.com/sites/testsite/_vti_bin/Lists.asmx" '?WSDL

listName = "TestList"

'the caml
batch = ""
batch = batch + " "
batch = batch + "  18"
batch = batch + "  1a1a1a"
batch = batch + "  1a.pdf"
batch = batch + "  Updated"
batch = batch + " "
batch = batch + ""

'soap wrapper plus some info in body
request =  ""
request =  request + ""
request =  request + "  "
request =  request + "  "
request =  request + "              " & Trim(listName) & ""
request =  request + "              " & Trim(batch) & ""
request =  request + "  "
request =  request + "  "
request =  request + ""

' build customer API request call using POST'
oXmlHTTP.Open "POST", sharePointURL, False, domainName &"\"& domainUserName, domainpassword

oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oXmlHTTP.setRequestHeader "SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"

oXmlHTTP.send Trim(request)

response = oXmlHTTP.responseText


Set oXmlHTTP = Nothing

Could You please tell me how to update list item based on CaseNumber and not using ID?

Thanks

  • You Need to get the list item and its ID by filtering list item based on CaseNumber and then update list item using the ID. you have to use ID for updating list item. – Ganesh Sanap Aug 20 at 6:44
  • Can You tell me how? I am totally new in SharePoint – Odyn Aug 20 at 7:13
  • Ok I solved my problem by INVOKING GetListItems() web service methood before my another script to update items. I am parsing response and obtainins ows_ID field which is required for update. Later adding this dictionary with CaseNumber key and perform update. – Odyn Aug 20 at 11:29
  • Great. Glad the approach worked for you. – Ganesh Sanap Aug 20 at 11:34
0

You have to use ID for updating list item.

Try following approach:

  1. First of all get the list item and its ID by filtering list item based on CaseNumber.
  2. Then update list item using the ID.
  • Hey, As this approach worked for you. Can you please accept it as a answer so that it will not be shown under Unanswered question section and it will get closed. – Ganesh Sanap Aug 23 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.