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!

  • 0
    I believe you put the info in AR_BillToSoldTo.
  • 0 in reply to TomTarget
    Yes, that much I have gathered. But I presume there is a method (line of code) to use that would add the customer as a sold to for another customer. I haven't found that in the documentation.
  • 0
    The AR_BillToSoldTo_bus class should do what you want. The key values to set are Sold To Division Number and Sold To Customer Number. After doing the SetKey(), you can then set the Bill To Division Number and Bill To Customer Number and write the record.
  • 0 in reply to Steve Passmore
    I'll give that a try - thanks!
  • 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