Question

Hello I'm Having problem getting the ExpensesList in Cheque in Quickbooks Here is my code:

bool sessionBegun = false;
            bool connectionOpen = false;
            QBSessionManager sessionManager = null;
            try
            {
                //Create the session Manager object
                sessionManager = new QBSessionManager();

                //Create the message set request object to hold our request
                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

                //Connect to QuickBooks and begin a session
                sessionManager.OpenConnection("", "Sample Code from OSR");
                connectionOpen = true;
                sessionManager.BeginSession(@"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\EsdeSolosyon.QBW", ENOpenMode.omDontCare);
                sessionBegun = true;

                ICheckQuery checkQueryRq = requestMsgSet.AppendCheckQueryRq();

                //Send the request and get the response from QuickBooks
                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
                IResponse response = responseMsgSet.ResponseList.GetAt(0);
                ICheckRetList checkRetList = (ICheckRetList)response.Detail;

                if (checkRetList != null)
                {
                    for (int i = 0; i < checkRetList.Count; i++)
                    {
                        ICheckRet checkRet = checkRetList.GetAt(i);
                        IExpenseLineRetList expenseList = checkRetList.GetAt(i).ExpenseLineRetList;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }

In my picture the expenseslist returns null and in my Quickbooks program enter image description here

But in my QuickBooks every cheque has expenses enter image description here

BTW in quickbooks you cannot add Cheque if you don't have any ExpensesList

Was it helpful?

Solution

It's the same issue as here: Why ExpenseLineRetList return null

A check request will not include the detail lines of the check unless you include it in your query. By adding the IncludeLineItems setting, you'll get access to the Expense or Item lists of the check (a check could have Expense lines, Item lines, or both). You'll want to change to include the following:

ICheckQuery checkQueryRq = requestMsgSet.AppendCheckQueryRq();

// Include the line details with the request
checkQueryRq.IncludeLineItems.SetValue(true);

//Send the request and get the response from QuickBooks
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
IResponse response = responseMsgSet.ResponseList.GetAt(0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top