Need help with UDS and GetChildObject method to access "AR_PaymentType_Bus"

SOLVED

Here's my situation:

The UDS is on the Pre-Totals event of S/O invoice header and I am trying to access a field in the "AR_PaymentType" table. I would appreciate if anyone could see by blunder in any of the 4 methods I describe here.

Methods I've tried:

  1. The oBusObj.GetDataSources() method indicates that "PaymentType" is a child of the invoice header, but the statement:
    Set oPaymentType = oBusObj.AsObject(oBusObj.GetChildHandle("PaymentType"))
    returns an error "Wrong number of arguments or invalid property assignment"
  2. If I separate the combined statements above into two:
    oPaymentType = oBusObj.GetChildHandle("PaymentType")
    retVal = oScript.DebugPrint(SCRIPT_ID & "oPaymentType = " & oPaymentType)
    	
    Set oPaymentType = oBusObj.AsObject(oPaymentType)
    retVal = oScript.DebugPrint(SCRIPT_ID & "oPaymentType = " & oPaymentType)
    the GetChildHandle method above returns oPaymentType = 100078 (which matches the variable "coPaymentTypeChild" value in a debug dump),
    but the Set statement gets the same error as in #1 above: "Wrong number of arguments or invalid property assignment".
  3. I tried using the existing variable "coPaymentTypeChild" directly in this statement:
    oPaymentObj = 0
    retVal = oBusObj.GetValue("coPaymentTypeChild", oPaymentObj)
    retVal = oScript.DebugPrint(SCRIPT_ID & "oPaymentObj = " & oPaymentObj)
    if oPaymentObj <> 0 Then
    		Set oPaymentObj = oBusObj.AsObject(oPaymentObj)
    the DebugPrint show oPaymentObj as 100078 (again, matching the variable "coPaymentTypeChild" value in a debug dump),
    but the Set statement gets an error "Invalid/Unknown property name, Wrong number of arguments or invalid property assignment (err/ret=2/0)"
  4. My final attempt is to access the "AR_PaymentType_Bus" table directly and "SetKey" to the specific PaymentType with both of the following statements (separately):
    Set oPaymentObj = oBusObj.AsObject(oBusObj.GetObject("AR_PaymentType_bus"))
    Set oPaymentObj = oSession.AsObject(oSession.GetObject("AR_PaymentType_bus"))
    Both these statements get the error message "Invalid/unknown property name, Wrong number of arguments or invalid property assignment (err/ret=2/0)"
     
Parents Reply Children
  • 0 in reply to David Speck

     This worked perfectly (minus the MoveFirst as it was already positioned correctly). Thank you AGAIN!!!  I just want to know why didn't the 1st method (as documented in multiple scripting resources including Steve M's) work?

    Hey  is there an award for the most helpful person in this forum? David deserves it!!!

  • 0 in reply to connex

    I stopped using statements that combined AsObject and GetObject, NewObject, or GetChildHandle because i don't like to have to use On Error Resume Next unless absolutely required to. Imho, it is much better to get the numeric value returned by the last three into its own variable, hence the "n" prefix, test it for not being equal to zero and if not, then set it as an object handle with a "o" prefix using AsObject. 

    Although the MoveFirst shouldn't be needed as i was just making sure that it really was going to the payment type table and not some other table. However, you may or may not need to include a [ReadAdditional "PaymentType"] before getting the child object or before getting your values from the child object. Have seen a few cases where the child object wasn't on the record i was expecting and ReadAdditional resolves that. If you don't pass it any arguments, it will read all child data sources so you can potentially save on resource overhead by just passing "PaymentType" to it so it will only read that child data source.

  • 0 in reply to connex

    - I agree there are a number of incredibly helpful individuals that continuously contribute on these forums and you should all be commended.  among two I know in particular, and you usually have the question answered before I can even read it. :)   Guess I'm getting obsolete Slight smile

    Thanks to everyone that makes this a real community!!!