我尝试使用vba代码修改现有Quickbooks Invoice中的订单项。我不断收到以下错误消息:
Invoice Mod
ORInvoiceLineModList:
element(2) - InvoiceLineMod:
TxnLineID: required field is missing
End of InvoiceLineMod
End of ORInvoiceLineModList
End of InvoiceMod
这是我用于构建请求的vba代码:
Set InvoiceModReq = msreq.AppendInvoiceModRq
With rsHDR
InvoiceModReq.TxnID.SetValue Nz(rsHDR![TxnNo], "")
InvoiceModReq.EditSequence.SetValue Nz(rsHDR![QBEditSequence], "")
InvoiceModReq.CustomerRef.ListID.SetValue Nz(rsHDR![QBListID], "")
If Nz(rsHDR![AcctgShipDate], "") <> "" Then
InvoiceModReq.TxnDate.SetValue rsHDR![AcctgShipDate]
End If
If Nz(rsHDR![ActualShipDate], "") <> "" Then
InvoiceModReq.ShipDate.SetValue Nz(rsHDR![ActualShipDate], "")
End If
InvoiceModReq.RefNumber.SetValue Nz(rsHDR![InvNo], "")
InvoiceModReq.PONumber.SetValue Nz(rsHDR![PONo], "")
InvoiceModReq.TermsRef.ListID.SetValue Nz(rsHDR![ptQBListID], "")
InvoiceModReq.SalesRepRef.ListID.SetValue Nz(rsHDR![raQBListID], "")
InvoiceModReq.ShipMethodRef.ListID.SetValue Nz(rsHDR![svQBListID], "")
InvoiceModReq.FOB.SetValue Nz(rsHDR!FOB, "")
InvoiceModReq.ClassRef.ListID.SetValue Nz(rsHDR![clQBListID], "")
'Line Items
If Nz(rsHDR![SealSales], 0) <> 0 Then
Set InvoiceLineModReq = InvoiceModReq.ORInvoiceLineModList.Append()
InvoiceLineModReq.InvoiceLineMod.TxnLineID.SetValue "1001"
Set rsLineItems = GetSalesOrder_LineItem_RecordSet(InvID, "Seal Strip")
If Nz(rsLineItems!QBListID) <> "" Then
InvoiceLineModReq.InvoiceLineMod.ItemRef.ListID.SetValue Nz(rsLineItems!QBListID)
End If
InvoiceLineModReq.InvoiceLineMod.Quantity.SetValue Nz(rsLineItems!Qty, 0)
InvoiceLineModReq.InvoiceLineMod.Amount.SetValue rsHDR![SealSales]
rsLineItems.Close
End If
If Nz(rsHDR![DeckleSales], 0) <> 0 Then
Set InvoiceLineModReq = InvoiceModReq.ORInvoiceLineModList.Append()
InvoiceLineModReq.InvoiceLineMod.TxnLineID.SetValue "1002"
Set rsLineItems = GetSalesOrder_LineItem_RecordSet(InvID, "Deckle")
If Nz(rsLineItems!QBListID, "") <> "" Then
InvoiceLineModReq.InvoiceLineMod.ItemRef.ListID.SetValue Nz(rsLineItems!QBListID)
End If
InvoiceLineModReq.InvoiceLineMod.Quantity.SetValue Nz(rsLineItems!Qty, 0)
InvoiceLineModReq.InvoiceLineMod.Amount.SetValue rsHDR![DeckleSales]
rsLineItems.Close
End If
我知道我需要指定TxnLineID和EditSequence,但我不知道如何捕获这些信息。
答案 0 :(得分:1)
在用于获取TxnID和TxnEditSequence的返回的InvoiceRet对象中,将有一个ORInvoiceLineRet。这是发票上所有订单项的列表。它是一个OR对象,因为该行可以是InvoiceLineRet或InvoiceLineGroupRet对象(组行由多个InvoiceLines和/或多个GroupLines组成)。
这些行中的每一行都有一个TxnLineID值,您需要为要修改的行提供该值。如果您尝试在所有发票行之后添加新行,则使用“-1”作为TxnLineID值。
如果您未对交易的订单项表进行任何更改,请不要包含 引用事务修改请求中的任何行。订单项表格将是 保留原样,完全忽略表格将加快处理请求。