Jump to content
Sign in to follow this  
dcat127

Using Com/obj with Quickbooks sdk

Recommended Posts

dcat127

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.

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
dcat127

I get the response "Object contains 0 elements"

What does this mean?

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
dcat127

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
  • Like 1

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.