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
  • 0
    SUGGESTED

    I was never able to get writing to the Sales Order Payment object to work for credit cards. What I did instead, is write the credit card to the customer, then reference the Credit Card ID on the sales order. This actually worked.

    Here are some code snippets:

    r = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_ui"))
    Set o = oScript.NewObject("SO_SalesOrder_bus", oSS)
    r = o.nSetKeyValue("SalesOrderNo$", SalesOrderNo)
    r = o.nSetKey()

    ...

    Set oPmt = o.oPaymentObj
    
    r = oPmt.oARCreditCard.nAddNewCreditCard(PaymentType, ccNumber, expirationYear, expirationMonth, guid)
    
    Set oCustCreditCard = oScript.NewObject("AR_CustomerCreditCard_bus", oSS)
    r = oCustCreditCard.nSetKeyValue("ARDivisionNo$", "00")
    r = oCustCreditCard.nSetKeyValue("CustomerNo$", CustomerNo)
    r = oCustCreditCard.nSetKeyValue("CreditCardGUID$", guid)
    r = oCustCreditCard.nSetKey()
    r = oCustCreditCard.nSetValue("PaymentType$", PaymentType)
    r = oCustCreditCard.nSetValue("CreditCardID$", CreditCardID)
    r = oCustCreditCard.nSetValue("ExpirationDateYear$", expirationYear)
    r = oCustCreditCard.nSetValue("ExpirationDateMonth$", expirationMonth)
    
    r = oCustCreditCard.nWrite()
    Set oCustCreditCard = Nothing
    
    r = oPmt.nAddDeposit()
    r = oPmt.nSetValue("CreditCardID$", CreditCardID)
    
    r = oPmt.nWrite()
    
    r = o.nWrite()

Reply
  • 0
    SUGGESTED

    I was never able to get writing to the Sales Order Payment object to work for credit cards. What I did instead, is write the credit card to the customer, then reference the Credit Card ID on the sales order. This actually worked.

    Here are some code snippets:

    r = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_ui"))
    Set o = oScript.NewObject("SO_SalesOrder_bus", oSS)
    r = o.nSetKeyValue("SalesOrderNo$", SalesOrderNo)
    r = o.nSetKey()

    ...

    Set oPmt = o.oPaymentObj
    
    r = oPmt.oARCreditCard.nAddNewCreditCard(PaymentType, ccNumber, expirationYear, expirationMonth, guid)
    
    Set oCustCreditCard = oScript.NewObject("AR_CustomerCreditCard_bus", oSS)
    r = oCustCreditCard.nSetKeyValue("ARDivisionNo$", "00")
    r = oCustCreditCard.nSetKeyValue("CustomerNo$", CustomerNo)
    r = oCustCreditCard.nSetKeyValue("CreditCardGUID$", guid)
    r = oCustCreditCard.nSetKey()
    r = oCustCreditCard.nSetValue("PaymentType$", PaymentType)
    r = oCustCreditCard.nSetValue("CreditCardID$", CreditCardID)
    r = oCustCreditCard.nSetValue("ExpirationDateYear$", expirationYear)
    r = oCustCreditCard.nSetValue("ExpirationDateMonth$", expirationMonth)
    
    r = oCustCreditCard.nWrite()
    Set oCustCreditCard = Nothing
    
    r = oPmt.nAddDeposit()
    r = oPmt.nSetValue("CreditCardID$", CreditCardID)
    
    r = oPmt.nWrite()
    
    r = o.nWrite()

Children