Consuming Web Services from SalesLogix VBScript

A really great thread has been evolving in the forums about consuming web services from SalesLogix VBScript plugins. Take a look:

Some highlights of the thread include Jason Huber’s post showing an example using the MS SOAP SDK (^):

I created a little WS at using .net although this isnt important.
I ensured I could view my WSDL by using the above link. My WSDL shows you that I have one function called ADD that accepts two ints and returns an int.

I also needed to install the Soap Toolkit on the client machine:

Dim soapClient3, strResult
Set soapClient3 = CreateObject(“MSSOAP.SoapClient30”)
Call soapClient3.mssoapinit(“”)
strResult = soapClient3.Add(3,4)

Timmus posted an example demonstrating calling the web service using XMLHTTP, passing some parameters to the web service, and parsing the XML results (^):

This web service accepts four parameters:

    [GetUser xmlns=""]

It then returns a user object that has 3 properties: FirstName (string), LastName (string), ReportsTo(user). This will give us the ability to see how nesting objects will be returned and parsed in the dom.

Here is the code calling the web service:

option explicit
dim oXMLDoc

Sub Button1Click(Sender)
set oXMLDoc = CreateObject("Msxml2.DOMDocument")
set oXMLHTTP = CreateObject("Msxml2.XMLHTTP.3.0")

oXMLHTTP.onreadystatechange = getRef("HandleStateChange")
call"POST", "http://localhost:3163/GetCurrentTime/Service.asmx/GetUser", false)
call oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
call oXMLHTTP.send("FirstName=Bill&LastName=Clinton&ReportsToFirstName=Hillary&ReportsToLastName=Clinton")

end sub

sub HandleStateChange
dim sFirstName
dim sLastName
dim sReportsToFN
dim sReportsToLN

if (oXMLHTTP.readyState = 4) then
dim szResponse: szResponse = oXMLHTTP.responseText

call oXMLDoc.loadXML(szResponse)
if (oXMLDoc.parseError.errorCode <> 0) then
call msgbox (oXMLDoc.parseError.reason)
sFirstName = oXMLDoc.getElementsByTagName("User")(0).childNodes(0).text
sLastName = oXMLDoc.getElementsByTagName("User")(0).childNodes(1).text
sReportsToFN = oXMLDoc.getElementsByTagName("User")(0).childNodes(2).childNodes(0).text
sReportsToLN = oXMLDoc.getElementsByTagName("User")(0).childNodes(2).childNodes(1).text

call msgbox(sFirstName & " " & sLastName & " reports to " & sReportsToFN & " " & sReportsToLN)

end if
end if
End Sub

As you can see the XMLDom is quite simple to traverse although I find it critical to have a good debugger so you can visually traverse the DOM. Once you can see it, you can code it

What an awesome discussion, and great stuff for any SalesLogix developer to follow! Thanks everyone!

Want content like this delivered to your inbox? Sign up for our newsletter!

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

1 Comment

  1. Hi! Excellent blog!

    I have tried to resolve the first name / last name of the current user via javascript in the onLoad function of an account form. It works with the UserId (using the WhoAmI / SOAP thing):

    var userid = xmlDoc.getElementsByTagName(“UserId”)[0].childNodes[0].nodeValue;


    How on earth do I get the first name and last name? I tried to use the information from your code, but the following didnt work:

    var userid = xmlDoc.getElementsByTagName(“User”)[0].childNodes[0].Text;

    Any ideas? Truely appreciate your help.


Submit a Comment

Your email address will not be published. Required fields are marked *