Scripting

  • 1.  Script to disallow 'obsolete' Ship To Address in SO Entry

    Posted 04-07-2026 15:59

    I cannot get this script to work because it is not reading in the UDF from the SO_ShipToAddress file.  I'm trying to fire a message and disallow the Ship to Address from being selected if it is marked as "obsolete" with a checkbox UDF (Y/N).

    'Desc: Do not allow SO Ship to Code to be used in SO Entry if Obsolete Ship To address UDF checkbox is selected on
    'Event: Post-Validate on Ship To code field

    '==========================================
    sObsShipTo = "" : sShip2Code = ""

    If oSession.CompanyCode <> "ZZZ" Then
    Exit Sub
    End If

    If oSession.StartProgram = "SO_SALESORDER_UI" Then

    Set oShipTo = oSession.AsObject (oSession.GetObject("SO_ShipToAddress_svc"))
    retVal = oShipTo.GetValue("UDF_OBSOLETE_SHIP_TO$", sObsShipTo)
    retVal = oScript.DebugPrint("Obsolete Ship To?: " & ObsShipTo)

    if sObsShipTo = "Y" Then
    retVal = oScript.SetError("Invalid/Obsolete Ship To Address.") 'Used to fail any of the "Pre" procedures
    retVal = oScript.InvokeButton("fldr.PHEADER")
    end if

    end If



    ------------------------------
    Jane Scanlan
    Partner
    Next Level Manufacturing Consulting Group
    ------------------------------


  • 2.  RE: Script to disallow 'obsolete' Ship To Address in SO Entry

    Posted 04-07-2026 16:24

    Your new object does not automatically load the correct record.  Do SetKeyValue on each of the key fields, then Find(), before the GetValue.

    Or you should be able to GetChildHandle instead of creating a new object... 

    retVal = oBusObj.ReadAdditional("ShipToCode")

    Set oShipTo = oSession.AsObject(oBusObj.GetChildHandle("ShipToCode"))



    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------