Plug-ins > FM Books Connector Online

Payment push LinkedTxn

(1/2) > >>

pjreagan:
I'm trying to export to a payment to QBO and link it to an existing QBO invoice but an error keeps getting thrown when I try to close the related LinkedTxn.  (Without linking, the payments export just fine.)  What am I doing wrong that causes the linking error to be thrown?

Here's my code...
Let([
date = cf_DateForQB(inv_INVOICELI__OnlyPayment_delete::DateOfService__d);
amount =  Round(inv_INVOICELI__OnlyPayment_delete::Cost_r_Payment; 2)];

PCQO_RqNew("Create"; "Payment") & ", " &
PCQO_RqAddFieldWithValue("TxnDate"; date) & ", " &
PCQO_RqAddFieldWithValue("PrivateNote"; inv_INVOICELI__OnlyPayment_delete::PaymentMemo__t) & ", " &
PCQO_RqAddRelatedRecord("Line") & ", " &
PCQO_RqAddFieldWithValue("Amount"; amount) & ", " &
PCQO_RqAddRelatedRecord("LinkedTxn") & ", " &
PCQO_RqAddFieldWithValue("TxnId"; "80") & ", " &
PCQO_RqAddFieldWithValue("TxnType"; "Invoice") & ", " &
PCQO_RsCloseRelatedRecord & ", " &

At this point the following error is thrown...
Error closing a related record
CODE: -990
SEVERITY: Exception
MESSAGE: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
SOURCE: mscorlib

Yes, an invoice with an Id of 80 does exist.
What index is the error referring to?
What collection is it referring to?





Not that it matters, but the remainder of my code after the error...
PCQO_RsCloseRelatedRecord & ", " &
PCQO_RqAddFieldWithValue("CustomerRef::Value"; $customerID) & ", " &
PCQO_RqAddFieldWithValue("DepositToAccountRef::Value"; $accountID) & ", " &
PCQO_RqAddFieldWithValue("PaymentMethodRef::Value"; $paymentMethodID) & ", " &
PCQO_RqAddFieldWithValue("PaymentRefNum"; inv_INVOICELI__OnlyPayment_delete::Client_PaymentReference_Number__t) & ", " &
PCQO_RqAddFieldWithValue("TotalAmt"; amount)
)

Jerel Malong:
Are you passing a negative value anywhere? the amount?

pjreagan:
The amount value is 100 for this test.  I even tried reversing the sign (0 - amount = -100) but that didn't help.  If someone could post code that works for them, it could be helpful.

Jerel Malong:
Here's what I have done in the past with no issues:

PCQO_RqNew( "Create" ; "Payment" )
...
various payment information
...
PCQO_RqAddRelatedRecord( "Line" )
PCQO_RqAddFieldWithValue( "LineNum" ; <LINE_VALUE> )
PCQO_RqAddFieldWithValue( "Amount" ; <AMOUNT_FIELD> )
PCQO_RqAddRelatedRecord( "LinkedTxn" )
PCQO_RqAddFieldWithValue( "TxnType" ; "Invoice" )
PCQO_RqAddFieldWithValue( "TxnId" ; <INVOICE_TXN_ID> )
PCQO_RqCloseRelatedRecord
PCQO_RqCloseRelatedRecord
....
continue with payment portion

Chris Turner:
Hi pjreagan,


--- Quote ---PCQO_RqNew("Create"; "Payment") & ", " &
PCQO_RqAddFieldWithValue("TxnDate"; date) & ", " &
PCQO_RqAddFieldWithValue("PrivateNote"; inv_INVOICELI__OnlyPayment_delete::PaymentMemo__t) & ", " &
PCQO_RqAddRelatedRecord("Line") & ", " &
PCQO_RqAddFieldWithValue("Amount"; amount) & ", " &
PCQO_RqAddRelatedRecord("LinkedTxn") & ", " &
PCQO_RqAddFieldWithValue("TxnId"; "80") & ", " &
PCQO_RqAddFieldWithValue("TxnType"; "Invoice") & ", " &
PCQO_RsCloseRelatedRecord & ", " &
--- End quote ---

In your script above, it looks like you're calling the CloseRelatedRecord function that is for the Response, not for the Request. Instead, when your script is generating the request, use "PCQO_RqCloseRelatedRecord" instead of "PCQO_RsCloseRelatedRecord".

So your request would look like this:

--- Code: ---PCQO_RqNew("Create"; "Payment") & ", " &
PCQO_RqAddFieldWithValue("TxnDate"; date) & ", " &
PCQO_RqAddFieldWithValue("PrivateNote"; inv_INVOICELI__OnlyPayment_delete::PaymentMemo__t) & ", " &
PCQO_RqAddRelatedRecord("Line") & ", " &
PCQO_RqAddFieldWithValue("Amount"; amount) & ", " &
PCQO_RqAddRelatedRecord("LinkedTxn") & ", " &
PCQO_RqAddFieldWithValue("TxnId"; "80") & ", " &
PCQO_RqAddFieldWithValue("TxnType"; "Invoice") & ", " &
PCQO_RqCloseRelatedRecord & ", " &
PCQO_RqCloseRelatedRecord & ", " &
PCQO_RqAddFieldWithValue("CustomerRef::Value"; $customerID) & ", " &
PCQO_RqAddFieldWithValue("DepositToAccountRef::Value"; $accountID) & ", " &
PCQO_RqAddFieldWithValue("PaymentMethodRef::Value"; $paymentMethodID) & ", " &
PCQO_RqAddFieldWithValue("PaymentRefNum"; inv_INVOICELI__OnlyPayment_delete::Client_PaymentReference_Number__t) & ", " &
PCQO_RqAddFieldWithValue("TotalAmt"; amount)
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version