views:

546

answers:

2

Hey guys,

I have been given the painful task of writing a C# application to sync up employee time entries in a separate database with Quickbooks. Since I'm brand new to QB programming, I'm trying to peform basic tasks, such as getting a list of customers, then jobs for each customer, then employees. I've been reading the SDK documentation, but I'm still a little fuzzy on the details because the examples I'm finding are a little too advanced for me at the moment :-P

To keep things simple, I would like to ask for a code snippet that gives me the list of customers for starters. Here's the code I've got:

        QBSessionManager SessionManager = new QBSessionManager();
        IMsgSetRequest customerSet = SessionManager.CreateMsgSetRequest("US", 8, 0);

        //          
        // Code to get list of customers here.
        //

        SessionManager.OpenConnection2("", "New App", ENConnectionType.ctLocalQBD);
        SessionManager.BeginSession(string.Empty, ENOpenMode.omDontCare);
        IMsgSetResponse Resp = SessionManager.DoRequests(customerSet);
        MessageBox.Show(Resp.ToXMLString());
        SessionManager.EndSession();
        SessionManager.CloseConnection();

Can anyone fill in the "code to get list of customers here" for me? Thank you very much in advance!

Victor

A: 

Ok, seems like I found the missing piece:

ICustomerQuery customers = customerSet.AppendCustomerQueryRq();

This produces all the data related to each customer, which is a step forward. Parsing the XML for customers should be pretty straightforward, but parsing the individual tasks/jobs for each customer will be laborious, because there are no subnodes for each task - basically you get repeating chunks of XML with all the basic customer info (address, billing address, shipping address, etc.), then this one property called "FullName" which appends a colon to the customer name, followed by the task title (which itself can be followed by another colon with a subtask title, etc.). I'm wondering if there's something clever I can do with the request query to get a better xml response (for instance, specify what properties I want returned, and maybe enforce the creation of subnodes for each task for a given customer)...comments are appreciated.

Yes you can specify which elements you want back from a query to limit the amount of communication. You can create with a query, though, you would have to do that in a separate step (if I understand you correctly). I'm familiar with the XML, not the SDK methods, so I can't give you exact details.
Yishai
A: 

Did you find an answer for this question.

Sarika