Desktop User Guides > Professional > Interview scripting > Using Interview Services > Salesforce Interview Service > Accessing the Salesforce service from mrScriptBasic
Accessing the Salesforce service from mrScriptBasic
The following script demonstrates how the service can be used outside of the Interview Services framework. The following mrScriptBasic script demonstrates how to create and configure the service and then creates a client object to query for the first and last names of all contacts. The results of the query are output to the console.
Replace the script's service.Username and service.Password values with valid values in your script.
Dim service
Dim client
Dim qr ' QueryResult
Dim done
Dim record
Dim fname
Dim lname
Dim iCnt

Set service = CreateObject("SalesforceService.Service")
service.URL = ""
service.Username = ""
service.Password = "xxxxxxxxPV8aBKpX2h5BwRBdjf8pQmzX"
Set client = service.ClientFactory.CreateClient() ' Auto logs the client in

' We are going to increase our return batch size to 250 items
' Setting is a recommendation only, different batch sizes may
' be returned depending on data, to keep performance optimized.
client.QueryOptionsValue.batchSize = 250
client.QueryOptionsValue.batchSizeSpecified = true

Set qr = client.query("select FirstName, LastName from Contact")
done = false

iCnt = 0
If (qr.size > 0) Then
Debug.Echo("User can see " + CText(Len(qr.records)) + " contact records.")

While Not done
For Each record in qr.records
' When using the Enterprise WSDL could convert the returned sObject
' to a Contact and use the properties of that. When using the
' Partner WSDL only have access to generic fields.
fName = record.fields[”FirstName”]
lName = record.fields[”LastName”]
If (fName = "") Then
Debug.Echo("Contact " + CText(iCnt + 1) + ": " + lName)
Debug.Echo("Contact " + CText(iCnt + 1) + ": " + fName + " " + lName)
End If
iCnt = iCnt + 1

If (qr.done) Then
done = true
qr = client.queryMore(qr.queryLocator)
End If
End While
Debug.Echo("No records found.")
End If

Set client = Null
Set service = Null
See also
Accessing the Salesforce service from the interview routing script
ISalesforceService interface
Salesforce Interview Service