Add Sold To Customer using scripting (National Accounts)

Hello All,

I've written a script where I'm creating new customer accounts.  I'm also looking for a method that will allow me to add these newly created customers as Sold To customers, but can't seem to find the answer in the materials.  Anyone have any input?

Thanks!

Parents Reply Children
  • 0 in reply to n0tgunshy1
    Here's my sloppy, but hopeful useful code, for anyone looking for it.

    'Create new AR Customer Business Object
    retVAL = oSS.nSetProgram(oSS.nLookupTask("AR_Customer_ui"))
    If retVal = 0 Then
    Msgbox "Unable to create customer object." & oss.sLastErrorMsg
    wscript.quit
    else

    Set oSoldToObj = oScript.NewObject("AR_BillToSoldTo_bus", oSS)
    End If

    retVal = oSoldToObj.nSetKeyValue("SoldToDivisionNo$", "01")

    if retval = 0 then
    msgbox oSoldToObj.sLastErrorMsg
    end if

    'if setting key value fails, do not proceed
    if retval <> 0 then
    retVal = oSoldToObj.nSetKeyValue("SoldToCustomerNo$", "CHILD")

    if retval = 0 then
    msgbox oSoldToObj.sLastErrorMsg
    end if
    end if

    'if setting key values fails, do not proceed
    if retval <> 0 then
    retVal = oSoldToObj.nSetKey()

    if retval = 0 then
    msgbox oSoldToObj.sLastErrorMsg
    end if
    end if

    'if set key fails, do not proceed
    if retval <> 0 then
    retVal = oSoldToObj.nSetValue("BillToDivisionNo$", "01")
    if retval = 0 then
    msgbox oSoldToObj.sLastErrorMsg
    end if

    retVal = oSoldToObj.nSetValue("BillToCustomerNo$", "PARENT")
    if retval = 0 then
    msgbox oSoldToObj.sLastErrorMsg
    end if

    retVal = oSoldToObj.nWrite()

    if retval = 0 then
    msgbox oSoldToObj.sLastErrorMsg
    end if
    end if