Author Topic: DataExtAdd to custom field in Invoice  (Read 6049 times)

Ferrell

  • Member
  • *
  • Posts: 7
DataExtAdd to custom field in Invoice
« on: November 17, 2010, 02:22:33 PM »
Having some trouble understanding the proper use of the DataExt functions, documentation is rather limited and well I need advice on the following.

I need to add a value to a custom field labeled as "REP" in the QuickBooks Invoice. I have tried the following

SetField [Main::gResult; PCQB_RqAddFieldWithValue( "DataExtName"; Main::REP)

I get the error -1000 stating Element 'DataExtName' is unexpected according to content model of parent element 'InvoiceAdd'. Obviously I am missing something regarding the use of DataExt and adding value to a PCQB_RqNew("InvoiceAdd";"")

I did see the following for SalesOrderAdd Request but that logic has not helped since when adding an invoice we need to use PCQB_RqNew( "InvoiceAdd";"" )

Sales Order Add Info in the forum:
The surefire way of adding a value for a custom field requires creating a DateExtMod request and populating the fields before executing.  The list of steps follows...

PCQB_RqNew( "DataExtMod" )
PCQB_RqAddFieldWithValue( "OwnerID"  ; "0" ) //OwnerID is always 0
PCQB_RqAddFieldWithValue( "DataExtName"  ; TheNameOfTheCustomField )
if( setting custom field in a transaction )
 #for setting the custom field in a txn...
 PCQB_RqAddFieldWithValue( "TxnDataExtType"  ; TxnType )
 PCQB_RqAddFieldWithValue( "TxnID"  ; TheTxnIDOfTheTxn )
 //the next line is only to apply the custom field value to the particular line item of the txn
 PCQB_RqAddFieldWithValue( "TxnLineID" ; TheTxnLineIDOfTheLineItemInTheTxn )
else if(setting for an entity or list item )
 #for setting the custom field in a list item
 PCQB_RqAddFieldWithValue( "ListDataExtType"  ; ListType )
 PCQB_RqAddFieldWithValue( "ListObjRef::ListID"  ; TheListIDOfTheItem )
end if
PCQB_RqAddFieldWithValue( "DataExtValue" ; TheValueForTheCustomField )

Valid values for the TxnType are:
ARRefundCreditCard, Bill, BillPaymentCheck, BillPaymentCreditCard, BuildAssembly, Charge, Check, CreditCardCharge, CreditCardCredit, CreditMemo, Deposit, Estimate, InventoryAdjustment, Invoice, ItemReceipt, JournalEntry, PurchaseOrder, ReceivePayment, SalesOrder, SalesReceipt, SalesTaxPaymentCheck, VendorCredit

Valid values for the ListType are:
Account, Customer, Employee, Item, OtherName, Vendor

Chris

  • God
  • Member
  • *****
  • Posts: 83
Re: DataExtAdd to custom field in Invoice
« Reply #1 on: November 18, 2010, 04:36:53 PM »
This is a 2 step process.  First create the invoice, then modify the DataExt object(s) related to that invoice.  The important thing to remember is that you are attempting to modify a DataExt object and not add a DataExt to an invoice. (The invoices related DataExt(s) are created when the invoice is created.

pseudo script....
#
#Perform your script to add the invoice without the DataExt value
...
...
#After the invoice is added be sure to capture the TxnID for the invoice.
Set Variable[ $TxnID......
#Now get the value for the "REP" field
Set Variable[ $Rep ; .....
#finally create a new request to modify the invoice's DataExt field that has the name "REP"
PCQB_RqNew( "DataExtMod" )
PCQB_RqAddFieldWithValue( "OwnerID"  ; "0" ) //OwnerID is always 0
PCQB_RqAddFieldWithValue( "DataExtName"  ; "REP")
PCQB_RqAddFieldWithValue( "TxnDataExtType"  ; "Invoice" )
PCQB_RqAddFieldWithValue( "TxnID"  ; $TxnID )
PCQB_RqAddFieldWithValue( "DataExtValue" ; $Rep)
PCQB_RqExecute
....

Chris

Ferrell

  • Member
  • *
  • Posts: 7
Re: DataExtAdd to custom field in Invoice
« Reply #2 on: November 18, 2010, 05:44:50 PM »
Chris it turns out that the field is not Custom, per the OSR the field is SalesRep and should be pushable via the PCQB_RqAddFieldWithValue but when trying to do that the plug-in responds back stating that it is not part of the InvoiceAdd Model. The field that needs to be pushed to is normally labelled "Rep" in the additional Customization of the QuickBooks Invoice Templates and is a field that is standard per the OSR as SalesRep. So baffled on this as the PCQB_RqAddFieldWithValue does not work. Further tried pulling the SalesRepQuery and get nothing yet there should be a list.

What am I missing or getting confused on between the FMBooks Connector (Missing details around this type of push pull) or the OSR ?

Ferrell

  • Member
  • *
  • Posts: 7
Re: DataExtAdd to custom field in Invoice
« Reply #3 on: November 18, 2010, 06:00:39 PM »
Correction field name per OSR is SalesRepRef and the same result

CODE: -1000
SEVERITY: failed validation
MESSAGE: Error at SalesRepRef
Reason:    Element 'SalesRepRef' is unexpected according to content model of parent element 'InvoiceAdd'.
Expecting: CustomerMsgRef, IsToBePrinted, IsToBeMailed, IsTaxIncluded, CustomerSalesTaxCodeRef, Other, ExchangeRate, LinkToTxnID, Invo....

Field Value:     TR


Ferrell

  • Member
  • *
  • Posts: 7
Re: DataExtAdd to custom field in Invoice
« Reply #4 on: November 18, 2010, 07:06:22 PM »
I have tried several variations of what you have posted with the DataExtMod and based on the following it fails.

1. Per OSR Field name: 'SalesRepRef'
2. Variation of field Name: 'SalesRep'
3. UI Label and field name in the Invoice "Additional Customization" name is 'Rep'

If I run it during the same session but after the first PCQB_RqExecute having established the TxnID I get a 3120 error "Attribute with specified Name" cannot be found regardless of the field name. I also get the same result if I run the DataExtMod as a separate session immediately after the execute and end session of the Invoice creation. This is working inside the Demo File Push Invoice to QB script.

Obviously the problem seems to be the name of the field and if it is a custom field or a standard field. Not sure what else I can do to make this work. Even though per the OSR in the InvoiceAdd the field name is 'SalesRepRef'

I have emailed Melinda a copy of the Script as a PDF file, too large for the forum,

Chris

  • God
  • Member
  • *****
  • Posts: 83
Re: DataExtAdd to custom field in Invoice
« Reply #5 on: November 19, 2010, 02:36:15 PM »
Was Melinda able to help you out?

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: DataExtAdd to custom field in Invoice
« Reply #6 on: November 21, 2010, 09:44:55 AM »
The sequence in which you pass an element's value to QB is not flexible and may be the source of the error your seeing. What element are you passing immediately before the SalesRepRef value? The "Reason" in the error message seems to indicate that the SalesRep element follows the Memo element. The OSR identifies the sequence required for QB to accept the data you're trying to send, so your solution may be relocating PCQB_RqAddFieldWithValue( "SalesRepRef" ; yourField ) step.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

Ferrell

  • Member
  • *
  • Posts: 7
Re: DataExtAdd to custom field in Invoice
« Reply #7 on: November 22, 2010, 11:41:22 AM »
Actually per Melinda it turned out to be that SalesRepRef had to be identified as "SalesRepRef::FullName" that being said I now have a problem pushing to fields defined via the Customer Centre and added to the invoice. The OSR does not appear to make a clear indication of how to use those fields.

Melinda DePalma

  • Member
  • *
  • Posts: 179
    • Productive Computing
Re: DataExtAdd to custom field in Invoice
« Reply #8 on: November 22, 2010, 01:30:50 PM »
For clarity and future reference in case anyone else runs into this issue, Ferrell was trying to push invoices from FM to QB and set the REP field (known as the “SalesRepRef” field in the OSR). The 2 attached screen shots show the following:

1) Script where the script step setting the "SalesRepRef" field was added.
2) Screen shot of the corresponding QuickBooks and FileMaker fields.