Author Topic: Push DataExt Custom Fields to Customer  (Read 1843 times)

markcutter

  • Member
  • *
  • Posts: 1
Push DataExt Custom Fields to Customer
« on: August 09, 2011, 02:39:47 PM »
The documentation is a bit light on the Push side of Custom Fields, and I'm wondering if there is a way to streamline the following code, patterned after topic,371.0 DataExtAdd to custom field in Invoice.
The goal is to edit regular and custom QB customer info in FM.  The following works, but doesn't seem very efficient with 4 separate invocations of RqExecute(). 
Is it possible to add the custom fields in the main execute?
Is it possible to combine the three custom fields into a single execute?
#Customer Fields
Set Variable [ $$Result; Value:PCQB_RqNew("CustomerMod" ; "" ) ]
Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListID" ; Main::gPush_Customer ListID ) ]
Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "EditSequence" ; Main::gPush_Customer Edit Sequence ) ]
Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "FirstName" ; Main::gPush_Customer First Name ) ]
#... set additional fields
Set Variable [ $$Result; Value:PCQB_RqExecute ]
Perform Script [ “Check for Errors”; Parameter: $Tab ]

#Customer Custom Fields
If [ Main::gPush_Customer_CC  "" ]
   Set Variable [ $$Result; Value:PCQB_RqNew( "DataExtMod" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "OwnerID" ; "0" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "DataExtName" ; "CC" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListDataExtType" ; "Customer") ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListObjRef::ListID" ; Main::gPush_Customer ListID) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "DataExtValue" ; Main::gPush_Customer_CC ) ]
   Set Variable [ $$Result; Value:PCQB_RqExecute ]
   Perform Script [ “Check for Errors”; Parameter: $Tab ]
End If
If [ Main::gPush_Customer_PreferredSend  "" ]
   Set Variable [ $$Result; Value:PCQB_RqNew( "DataExtMod" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "OwnerID" ; "0" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "DataExtName" ; "Preferred Send Method" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListDataExtType" ; "Customer") ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListObjRef::ListID" ; Main::gPush_Customer ListID) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "DataExtValue" ; Main::gPush_Customer_PreferredSend ) ]
   Set Variable [ $$Result; Value:PCQB_RqExecute ]
   Perform Script [ “Check for Errors”; Parameter: $Tab ]
End If
If [ Main::gPush_Customer_Pricing  "" ]
Set Variable [ $$Result; Value:PCQB_RqNew( "DataExtMod" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "OwnerID" ; "0" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "DataExtName" ; "Pricing" ) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListDataExtType" ; "Customer") ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ListObjRef::ListID" ; Main::gPush_Customer ListID) ]
   Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "DataExtValue" ; Main::gPush_Customer_Pricing ) ]
   Set Variable [ $$Result; Value:PCQB_RqExecute ]
   Perform Script [ “Check for Errors”; Parameter: $Tab ]
End If

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 468
Re: Push DataExt Custom Fields to Customer
« Reply #1 on: August 10, 2011, 06:52:19 AM »
You wrote:

> Is it possible to add the custom fields in the main execute?

Only the LineAdd elements in Purchase Order and AR-side (CM, Estimate, Invoice, etc.) transactions accept DataExt elements in an Add request. Intuit painted themselves into a corner with their implementation of Custom Fields and I think we're unlikely to see much improvement in our ability to address them. Even these transactions initially required a separate DataExt request for every Custom Field in every Line on the transaction. It was a huge hassle and was likely changed only because as each DataExt request was processed it would change the value of the TimeModified element for the transaction.

> Is it possible to combine the three custom fields into a single execute?

I believe QB allows you to pass multiple requests in a single execute, but I've never tried it with FMBooks native functions. I don't remember how QB dealt with a failed request included with others (that would have succeeded if passed by themselves) the last time I tested that situation. I do know that I made it a practice to hand off requests one at a time and I've stuck with that practice for more than 8 years.

I agree, at least in principle, that it seems inefficient. In practice, DataExt add requests almost always return their result in less than a second as long as the connection to QB is already established. Bear in mind the impact alluded to above: each successful DataExt request will update the TimeModified element of the ObjRef, and if that value is something you're tracking in FM, you'll need to update it appropriately.

HTH!

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