Sage 100

 View Only
  • 1.  Scripting Help Needed: Ship to Address in PO Entry

    Posted 11-25-2020 16:02
    I've created a script to automatically populate the Ship To Address Code, depending on what warehouse code is assigned to the PO header.  It is not working and am hoping that someone can offer me some help.  I'm obviously less than a novice when it comes to scripting, but thought I could at least do this simple script ... but no I can't.

    'Title: PO_Dflt_Ship_To
    'Desc: Get Ship To Code based on Warehouse Code
    'Bus Object: PO_PurchaseOrderHeader
    'Event: Table Pre-Write
    'By Jane Scanlan

    '

    ' -------------------------SCRIPT START ------------------------------------

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

    sWhse = "" : sShipTo = ""

    retVal = oBusObj.GetValue("WarehouseCode$", sWhse)
    retVal = oScript.DebugPrint("Warehouse = " & sWhse)
    retVal = oBusObj.GetValue("ShipToCode$", sShipTo)
    retVal = oScript.debugPrint("Ship To Code = " & sShipTo)

    if sWhse = "100" then
    retval = oBusObj.setValue("ShipToCode$",100)

    if sWhse = "200" then
    retval = oBusObj.setValue("ShipToCode$",200)

    if sWhse = "300" then
    retval = oBusObj.setValue("ShipToCode$",300)

    end if

    end if

    end if


    ------------------------------
    Jane Scanlan
    Partner, Next Level Manufacturing Consulting Group
    Next Level Manufacturing Consulting Group
    Chanhassen MN
    952-210-7758
    ------------------------------


  • 2.  RE: Scripting Help Needed: Ship to Address in PO Entry

    Posted 11-25-2020 17:03
    The value you are setting a string variable to needs to be a string rather than an integer:
    if sWhse = "100" then
    retval = oBusObj.setValue("ShipToCode$","100")

    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------



  • 3.  RE: Scripting Help Needed: Ship to Address in PO Entry

    Posted 11-25-2020 17:06
    Or if 100,200 & 300 are all the warehouses then:
    retval = oBusObj.setValue("ShipToCode$",sWhse)
    instead of the three if/then statements


    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------