function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
steven75steven75 

Classic ASP / VBScript Connection

Hi,

 

I am trying to connect to SalesForce using Classic ASP.   I have downloaded the "SForce Office Toolkit.msi" version 4 and installed on my web server.  I attempted to use this code below (found in this forum), but could connect to SalesForce. 

<%
Dim SforceApi
Dim sObject(0)
 
Set SforceApi = server.CreateObject("SForceOfficeToolkit4.SForceSession4.0")

if SforceApi.Login("mylogin","mypassword_and_securityToken") then
    Set sObject(0) = SforceApi.CreateObject("Lead")
   
    sObject(0).Item("FirstName").value = "Test"
    sObject(0).Item("LastName").value = "Testing"

     if SforceApi.Create(sObject,false) then
         Response.Write "Correct insert "
     else
          Response.Write "Error on insert"
     end if
else
     response.Write "login failed"
end if

Set SforceApi = nothing
Set sObject(0) = nothing
%>

 

Any advice, please?

Best Answer chosen by Admin (Salesforce Developers) 
steven75steven75

That link is very helpful.  Thanks alot for being patient and helpful.  Appreciated!

All Answers

SuperfellSuperfell

What goes wrong?

steven75steven75

So it removed the "0" in the object, and it seemed to passed the login like this below.

Set SforceApi = server.CreateObject("SForceOfficeToolkit4.SForceSession4")

 

Then, it complained the required the company name, then I add the Company like below and it said "Insert Error".   Not sure what I need to do.

<%
Dim SforceApi
Dim sObject(0)
 
Set SforceApi = server.CreateObject("SForceOfficeToolkit4.SForceSession4")

if SforceApi.Login("username","password_token") then
    Set sObject(0) = SforceApi.CreateObject("Lead")
   
    sObject(0).Item("FirstName").value = "IIS_FirstName"
    sObject(0).Item("LastName").value = "IIS_LastName"
    sObject(0).Item("Company").value = "IIS_Company"

     if SforceApi.Create(sObject,false) then
         Response.Write "Correct insert "
     else
          Response.Write "Error on insert"
     end if
else
     response.Write "login failed"
end if

Set SforceApi = nothing
Set sObject(0) = nothing
%>

----------------------------------------------------------------

I also try this following to see if I can loop through and list all the account names.   but no luck.

 

<%@ Language="VBScript" %>
<%
dim g_sfApi
function login(username, password)
    set g_sfApi=Server.CreateObject("SForceOfficeToolkit4.SForceSession4")
    login=g_sfApi.Login("username","password_token")
end function
%>

<body>
<%
dim lr, sid, serverUrl, row, rc
dim qr' as QueryResultSet3
dim s' as SObject3
'lr = login(username, password1)
lr=login(username2,password2)
if not lr then
    Response.Write("Login Failed")
else
    set qr=g_sfApi.Query("select * from account",false)
end if


while not qr.EOF
   response.write(qr("name"))
   qr.noveNext
wend
   
%>

 I am getting this error below.  It doesn't know EOF.

  error '800a01b6'

Microsoft VBScript runtime

Object doesn't support this property or method: 'EOF'

/test/sf2.asp, line 24

 

Please help,

Thanks,

SuperfellSuperfell

There is no EOF on query Result, have you seen the office toolkit docs ? http://www.salesforce.com/us/developer/docs/officetoolkit/index.htm

steven75steven75

That link is very helpful.  Thanks alot for being patient and helpful.  Appreciated!

This was selected as the best answer
steven75steven75

Simon,

 

One more question.   I was successfully connected to the free test account (Enterprise), but when I try this for the real production account (Professional),  I was getting login failed error and I have double-check username/password multiple times to make sure it correct.   Could it be because of the free test account has "enabled" OfficeTool somewhere, and production account is "disabled"?  Or the Professional version doesn't support OfficeToolKit?

 

Thanks,

SuperfellSuperfell

Professional Edition doesn't include API access.

Mattias NordinMattias Nordin

Why not post a working example an tag that as your answer? =)