Jump to content

Using Com/obj with Quickbooks sdk


Recommended Posts

I am trying to use Autoit with Quickbooks sdk to retrieve the customer list.

$sessionMan = ObjCreate("QBFC8.QBSessionManager.1")
If Not IsObj($sessionMan) Then MsgBox(0, "ERROR", "Session Management: Unable to create object.")
$sessionMan.OpenConnection("myapp2", "myapp2")
$sessionMan.BeginSession("", 2)
$reqMsgSet = $sessionMan.CreateMsgSetRequest("US", 1, 1)

$customerQuery = $reqMsgSet.AppendCustomerQueryRq()
$ListMergeSampleResp = $sessionMan.DoRequests($reqMsgSet)

MsgBox(0, "", $ListMergeSampleResp)
;   Close the session and connection with QuickBooks.
$sessionMan.EndSession
$sessionMan.CloseConnection

I am able to connect successfully, and Quickbooks pauses about the right amount of time to retrieve the customer list when line 8 is executed.

The msgbox however does not contain any information. Am I doing some thing that is obviously wrong? This is the first time I am working with com/obj.

Thanks for any help.

Link to comment
Share on other sites

I would expect $ListMergeSampleResp to be returned as a collection object or something similar. Try:

$ListMergeSampleResp = $sessionMan.DoRequests($reqMsgSet)
If IsObj($ListMergeSampleResp) Then
    $iCnt = 0
    For $oSampleResp In $ListMergeSampleResp
        $iCnt += 1
    Next
    MsgBox(64, "Object", "Object contains " & $iCnt & " elements")
Else
    MsgBox(16, "Not Object", "Not and object")
EndIf

That will tell you if it's an object, and if that object is a collection.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

First impression is that you got an empty collection. We don't have the SDK, you do. How does it describe the method you called and the return value from it?

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Looks like I missed:

$output = $ListMergeSampleResp.ToXMLString()

This code now returns an xml string with the customer list

$sessionMan = ObjCreate("QBFC8.QBSessionManager.1")
If Not IsObj($sessionMan) Then MsgBox(0, "ERROR", "Session Management: Unable to create object.")
$sessionMan.OpenConnection("myapp2", "myapp2")
$sessionMan.BeginSession("", 2)
$reqMsgSet = $sessionMan.CreateMsgSetRequest("US", 1, 1)

$customerQuery = $reqMsgSet.AppendCustomerQueryRq()
$ListMergeSampleResp = $sessionMan.DoRequests($reqMsgSet)
$output = $ListMergeSampleResp.ToXMLString()

MsgBox(0, "", $output)
;   Close the session and connection with QuickBooks.
$sessionMan.EndSession
$sessionMan.CloseConnection
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...