Reputation: 31
I want to get custom S.O. Invoice Template fields using QuickBooks QBFC.
Upvotes: 3
Views: 2023
Reputation: 13077
Here's how to read custom fields from a sales order:
OwnerIDList
of the SalesOrderQuery
.DataExtRetList
that is attached to SalesOrderRet
objects that are returned from the query.DataExtRetList
in the SalesOrderLineRet
and SalesOrderLineGrouptRet
objects that are included in each SalesOrderRet
(if you're reading line items).If you're already using the IncludeRetElementList
, you must add DataExtRet
to the list; if you're not then don't start using IncludeRetElementList
until you have custom fields working. Just like any transaction query, you won't see any line item data unless you set the IncludeLineItems
flag in the request.
Custom fields are well documented in the QuickBooks SDK Manual. I'd recommend you take a look at the section DataExt: Using Custom Fields and Private Data in the QBSDK Programmers Guide.
Upvotes: 4
Reputation: 1141
To elaborate on Paul Keister's answer, the reason you must add "0" to the query is because that is the Owner ID of the custom field you are attempting to retrieve. 0 is probably likely to be the value, but if the owner ID is different, you will have to use a different value here.
Some example C# code:
//set the owner id of the custom field you are trying to get back
IInvoiceQuery invoiceQuery = requestMsgSet.AppendInvoiceQueryRq();
invoiceQuery.OwnerIDList.Add("0");
//set up query parameters and actually call your query...
//call this method for each invoice to get its custom fields (if they exist)
static void GetInvoiceCustomFields(IInvoiceRet invoice)
{
if (invoice.DataExtRetList == null)
{
return;
}
for (int i = 0; i < invoice.DataExtRetList.Count; i++)
{
IDataExtRet extData = invoice.DataExtRetList.GetAt(i);
Console.WriteLine("external data name: " + extData.DataExtName.GetValue());
Console.WriteLine("external data value: " + extData.DataExtValue.GetValue());
}
}
Upvotes: 2