Sage 100

 View Only
  • 1.  Script variable issue

    Posted 09-04-2020 01:15
    Hi All,
      Working on a script that is intended to read the PO line required date and if it is changed, to then go out and update the promise date on Sales Order lines.  I am running into a problem getting it to store the variables. In the trace, it shows that both of these are writing out as 0.   Not sure what is wrong.   The first script (the one storing the variables is a post read and the second that is to trigger the update of the SO's is a Post Write.  Here is the first script that doesn't write out the variables.   What am I doing wrong?

    'Update Sales Order Promise Date when PO Item required data is updated
    'Post Read step
    'Bob Osborn, ACI 9/2020

    Debug_Flag = 0 : BadStart = 0 : UI = 0 : BOI = 0
    StartProgram = Trim(UCase(oSession.StartProgram))
    If Right(StartProgram,3) = "_UI" Then UI = 1

    If (UI=0) Then BadStart = 1
    If BadStart > 0 Then Exit Sub

    if oSession.CompanyCode = "ABX" Then

    sItemType = ""
    retVal = oBusObj.GetValue("ItemType$", sItemType)
    If sItemType <> "1" Then
    retMsg = oSession.AsObject(oSession.UI).MessageBox("", sItemType)
    Exit Sub
    End If

    sOriReqDate = "" : SOriItemCode = ""

    retVal = oBusObj.GetValue("RequiredDate$",sOriReqDate)
    retVal = oBusObj.GetValue("ItemCode$", sOriItemCode)
    retVal = oScript.SetStorageVar("OriReqDate", sOriReqDate)
    retVal = oScript.SetStorageVar("OriItemCode", sOriItemCode)
    'retMsg = oSession.AsObject(oSession.UI).MessageBox("", sOriReqDate)
    End If

    Thanks in advance!

    ------------------------------
    Bob Osborn
    Consultant
    ACI Consulting
    ------------------------------


  • 2.  RE: Script variable issue

    Posted 09-04-2020 22:42
    Each business object's script object has its own storage variables but if both of your scripts are on the same object, in this case, PO_PurchaseOrderDetail, then this shouldn't be an issue.

    In your second script, are you first initializing the variables to an empty string ("") before passing them to oScript.GetStorageVar?

    Are you positive you are using GetStorageVar and not SetStorageVar in the event you copied and pasted between the scripts but forgot to change Set to Get?

    ------------------------------
    David Speck II
    Tennessee Software Solutions
    ------------------------------