Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Script causes sales order to freeze

mandm, I would try commenting out all calls to MessageBox() to see if that helps determine the cause of the freezing. If that is the case, you might see some ProvideX processes that crashed on the server.

 

I've encountered the MessageBox freezing issue numerous times in 4.4 and had to disable them due to this problem. Along the way, I came up with a method that uses the standard VBScript function "MsgBox" for event scripts. It should also work for a button script that is executed on the server (in your case?). It's a rather crude solution to perform such a simple task, but I can organize it all up if you think it will help you. Hopefully, Elliott or someone else has an easy and more elegant solution.

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010

Re: Script causes sales order to freeze

I currently use this for Sales Order Entry (Header) on a Table Post-Read event. I think it can be easily applied to a button script that is run on the server. So far, it seems completely stable and I have yet to see a ProvideX crash on the server.

 

1) Create a UDF that will store the text that you want to display to the user (e.g. UDF_MSGBOX_TEXT$) with a large enough length for the message. This will serve as a parameter to be sent from the event script.

 

2) Create a custom button on the main panel (DMAIN/DMAINW, not on a tab). Initially it can be visible, but on a live system, it should be hidden.

 

3) In the event script, you'll have your regular code and when you want to display a message box, set the value of UDF_MSGBOX_TEXT$ to the text you send to the user and invoke the custom button.

retVal = oBusObj.SetValue("UDF_MSGBOX_TEXT$", strMessage)
oScript.InvokeButton("BT_LINK_1")

 

4) Back in Customizer, Add UDF_MSGBOX_TEXT$ to the list of variables to be passed to the MS script for the custom button, which will execute the actual MsgBox function.

MsgBox SO_SalesOrder_bus_UDF_MSGBOX_TEXT, , "MAS 200 Custom Message"

 

Note that this would only work as an informational message box (OK) but not a decision one (Yes/No/Cancel). I think it's possible but it would be very tricky to continue working under the client side code in contrast to the normal BOI. Another drawback is that adding a UDF that is large in size will of course take up more space than most other smaller fields, unless there is a better way of passing a parameter to the client button script. Some other fine experts here may be able to revise and shorten this procedure.

 

HTH

Regular Contributor
Gator
Posts: 269
Registered: 12-05-2008
0

Re: Script causes sales order to freeze

Nice.  I did something similar along these lines to launch a button script from the business object side of things.  I never thought to do what you did here, but I see this will work great.  Thanks for the post!

Regular Contributor
Gator
Posts: 269
Registered: 12-05-2008
0

Re: Script causes sales order to freeze

I wonder if a SetStorageVar, GetStorageVar would work here.  This would avoid the need of a UDF as the value would only reside in memory while the program is running.

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Script causes sales order to freeze

[ Edited ]

Glad to help, Gator! Yes, that is really the trick in order for this to work which I learned in another post some time ago.

 

EDIT: Oh, that is worth a shot. I'm not very familiar with those methods, but hopefully it might work and save space.

Sage Employee
jepritch
Posts: 233
Registered: 08-25-2009
0

Re: Script causes sales order to freeze

roland, thanks for the work around, and gator using the SetStorageVar and GetStorageVar should work, if you use the ones from the oSession object. 

 

retVal = oSession.SetStorageVar("messageText", "Message text")

 

then in the custom button script

 

retVal = oSession.GetStorageVar("messageText",  msgTxt)

MsgBox msgTxt, "MAS 200 Custom Message"

 

I haven't tried this, but I think should work.  Let us know!

 

Elliott

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Script causes sales order to freeze

Thanks Elliott! I'll try this out at the end of the day.

 

Just wondering, is the Session object still accessible if the custom button is set to execute the script on the client? I believe if I set the script to execute on the server, the MsgBox will appear on the server of course instead of the client's workstation.

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Script causes sales order to freeze

It appears that this did not work. Couple of things - I received the error below, then I noticed the Get & SetStorageVar should be called from oScript instead of oSession, but I still received the error for oScript, which makes sense since the script for GetStorageVar is executed in client's VBScript side instead of BOI or server side.

 

OLE Error Number : 424

Description : Object required: 'oSession'

Language : VBScript

Script Line : 27

Script Column : 0

 

Any other expert suggestions would be greatly appreciated.

Regular Contributor
Gator
Posts: 269
Registered: 12-05-2008
0

Re: Script causes sales order to freeze

[ Edited ]

What about creating a oSession level oScript object handle?

 

oSS_Script = 0

if Not(IsObject(oSS_Script)) then
Set oSS_Script = oSession.AsObject(oSession.ScriptObject)
end if

 

EDIT:  When I get time, I'll try to test this too (won't be today).

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Script causes sales order to freeze

Thanks Gator, I'll test it on our live system later as well.