Sage 100

 View Only
  • 1.  Button Script using InvokeButton(BT_ACCEPT) is lacking

    Posted 09-10-2019 13:13
    Edited by Dan Burleson 09-10-2019 13:23
    #scripting

    I wrote a server side button script as a replacement Accept button in Shipping Data Entry that does quantity available checking and, if successful, invokes the real Accept button.

    The problem is that using InvokeButton("BT_ACCEPT") does not do everything that clicking the actual Accept button does.

    1. It does  not do a quick print of the picking sheet (Okay, adding InvokeButton("BT_QUICKPRINT") does that)
    2. It does not change the invoice field ShipStatus to "Lines Complete", rather it stays as "New"
    3. It does not check whether any lines are left with zero lines shipped and zero lines backordered then, if there are, puts up a warning whether to
      accept these lines with a choice of Yes, No or Backorder.
    Is there a way to perform the REAL Accept function without having to emulate all the missing elements above? I see a function called BT_ACCEPT() in the SHIPPING_UI. Is that something that could be used? ​

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------


  • 2.  RE: Button Script using InvokeButton(BT_ACCEPT) is lacking

    Posted 09-10-2019 13:29
    Edited by Alnoor Cassim 09-10-2019 13:41
    * EDIT * fixed typos
    ----------------
    In ProvideX it would just be _OBJ'BT_Accept() therefore instead of InvokeButton("BT_ACCEPT") you could try :

    oScript.Execute "_OBJ'BT_Accept()"

    But with scripting the _OBJ may hold a value of 0 at this point (b/c it out of scope) for the UI object handle. If you get an error (like execute Error 65) here is 1 way of dealing with it:

    Run a Panel PostLoad script on DMAIN(w) to get actual UI object handle value
    myUIObj = oScript.Evaluate("_OBJ")
    'now save off with SetStorageVar or to a UDF

    On you button script, get the myObj value from GetStorageVar or UDF then

    oScript.Execute "tmpUIObj = " & myUIObj
    oScript.Execute "tmpUIObj'BT_Accept()"


    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 3.  RE: Button Script using InvokeButton(BT_ACCEPT) is lacking

    Posted 09-10-2019 15:27
    Thank you for the response! I like these ideas, however I cannot get the storage var to come through to the button script with the oScript version of Set/GetStorageVar (see attached graphic). The oSession version does not work in the button script(Error 88: "Object doesn't support this property or method: 'oSession.GetStorageVar' ")

    For the UDF option, I don't see an object in the PostLoad to which I could create a UDF. Since the invoice isn't loaded yet, I don't know of an object that is unique to the session at that point in time.


    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 4.  RE: Button Script using InvokeButton(BT_ACCEPT) is lacking
    Best Answer

    Posted 09-10-2019 22:27
    Edited by Dan Burleson 09-11-2019 14:43
    Dan - I took a very close look now and good news / bad news / hopeful news.

    GOOD NEWS: With following adjustments you can make the StorageVars work:

    'In Panel PostLoad of DMain(w)
    If oSession.StartProgram = "SO_SHIPPING_UI" Then
    myUIObj = 0
    myUIObj = oScript.Evaluate("_OBJ")

    Set oBizScript = oSession.AsObject(oSession.ScriptObject) 'have to do this to travel from UI to _bus
    retVal = oBizScript.SetStorageVar("var_MyUIObj", myUIObj) 'Value is coincidentally 100010 for most screens
    End If
    __________________________________________________
    'In button
    myUIObj = 0
    retVal = oScript.GetStorageVar("var_MyUIObj", myUIObj)
    r=oScript.DebugPrint("myUIObj = " & myUIObj)
    oScript.Execute "tmpUIObj = " & myUIObj
    'All that above works for me

    'This next part works from UDS but not button script but it's a moot point anyway cuz of the Bad News below
    oScript.Execute "rVal=EVN(" + Chr(34) + "tmpUIObj'BT_Accept()" + Chr(34) + ")"

    BAD NEWS:
    I realized even if you do _OBJ'BT_Accept() in pvx, it still behaves exactly the way you described your problem. A further look at SO_Shipping_ui.pvc code shows it is actually checking if the last control (via mouseclick or keyboard shortcut) was the actual BT_ACCEPT button (meaning InvokeButton and _OBJ'BT_Accept() don't count) and only then does all the other stuff happen with the Lines Complete, quick printing the Packing List, etc.

    HOPEFUL NEWS:
    So it is designed in a limited way and could be considered a scripting bug. I'm hopeful you can change your button to Execute from Client then try the good ole SendKeys("%A") which of course may be too deprecated to work but worth a try.

    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 5.  RE: Button Script using InvokeButton(BT_ACCEPT) is lacking

    Posted 09-10-2019 22:54
    Thanks @Alnoor Cassim! I always learn something new from your posts. I appreciate your looking into this.  I had the SendKeys in my back pocket from days gone by, but with a different short cut key ("t") so that any keyboardists would get my replacement Accept button. I also had to add "{Enter}" to it (i.e. SendKeys("%t{Enter}") that I don't remember having to do in the past. I will just have to hope that a particularly long order won't cause a loss of window focus and send those keys to another app.

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------