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 _busretVal = oBizScript.SetStorageVar("var_MyUIObj", myUIObj) 'Value is coincidentally 100010 for most screensEnd If__________________________________________________
'In buttonmyUIObj = 0retVal = 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 belowoScript.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.bizOrange County, CA
------------------------------
Original Message:
Sent: 09-10-2019 15:26
From: Dan Burleson
Subject: Button Script using InvokeButton(BT_ACCEPT) is lacking
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
------------------------------
Original Message:
Sent: 09-10-2019 13:29
From: Alnoor Cassim
Subject: Button Script using InvokeButton(BT_ACCEPT) is lacking
* 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