Sage 100

 View Only
  • 1.  Why won't the script error message appear

    Posted 04-25-2022 12:34
      |   view attached
    Oh please tell me where I've gone wrong.  I'm trying to get a simple message to pop up in SO entry.  This is on version 2021 Premium.   Below is my script.  I've also tried retVal = oScript.SetWarning.  Please see the attached image which shows that the script is running - it's just the message that won't pop.  I have this script set at Column Post-Validate on the UDF_STATE field on the SO_SalesOrderHeader.

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

    retVal = oScript.DebugPrint("California DOT Script is running.")

    sDOT = "" : sState = ""

    retVal = oBusObj.GetValue("UDF_DOT$", sDOT)
    retVal = oScript.DebugPrint("DOT = " & sDOT)
    retVal = oBusObj.GetValue("UDF_STATE$", sState)
    retVal = oScript.DebugPrint("State = " & sState)

    if sDOT = "Y" and sState = "CA" then
    retVal = oScript.SetError("Do NOT quote BNX! Instead quote Griptwist Male plus TDX.")

    End If

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


  • 2.  RE: Why won't the script error message appear

    Posted 04-25-2022 14:23
    Unless I am mistaken, you should be getting down to your final if statement, but I always like to verify ... either change your SetError to a DebugPrint, and maybe also an Else that DebugPrints "Failed" or something ... also, might want to check retVal on the SetError to see what it is..

    ------------------------------
    Randy Marion
    ------------------------------



  • 3.  RE: Why won't the script error message appear

    Posted 04-25-2022 15:07
    Edited by Jane Scanlan 04-25-2022 15:07
    Elliott commented that "There is a SetWarning() method you can use that should do that.  It's a "little" hit and miss depending on the Sage logic, but give it a try.  Either that or you could use coSession.UI.MessageBox() method if it doesn't work.   

    I already had tried the SetWarning option instead of SetError and the message would not pop.  I instead then tried the other option which fired the message, but it fired it twice.  Waiting to hear back from him again on SageCity.

    if sDOT = "Y" and sState = "CA" then
    oSession.AsObject(oSession.UI).MessageBox "","Do NOT quote BNX! Instead quote Griptwist Male plus TDX."


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



  • 4.  RE: Why won't the script error message appear

    Posted 04-25-2022 15:57
    SetError depends on a "Pre" event... (Column Pre-Validate, Table PreWrite...).  What event are you using?

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



  • 5.  RE: Why won't the script error message appear

    Posted 04-25-2022 16:00
    Column Pre-Validate - that is what Elliott said to use.

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



  • 6.  RE: Why won't the script error message appear

    Posted 04-25-2022 16:04
    That is not what your OP says... which refers to Post-Validate, which will not work.


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



  • 7.  RE: Why won't the script error message appear

    Posted 04-25-2022 16:08
    Kevin,

    I don't understand why you say it won't work, because it does work with Column Pre-Validate - it just pops the message box twice now and that is what I'm waiting on for Elliott to respond on Sage City.

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



  • 8.  RE: Why won't the script error message appear

    Posted 04-25-2022 16:14
    SetError is tied to a pre-event, with the primary function of blocking the change (and also giving the pop-up).  A "Post" event is after the change is done, so the primary purpose of SetError is bypassed, and nothing is done.
    Using a MessageBox is better when you just want an informational pop-up.  If it's coming up more than once, check for another event / script that might be triggering it more than once.
    MAS_UI = False
    if oSession.UI <> 0 and oBusObj.FromScanForce <> 1 then
    MAS_UI = True
    end if
    if MAS_UI then
    retVal = oSession.AsObject(oSession.UI).MessageBox("","Words:  " & sStringVar)
    end if


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