Inconsistent Behaviour & Odds and Sods – Trouble In Paradise

Without belabouring the point, Smart Office rocks, but some things about it are immensely frustrating…ok, ok, the actual immensely frustrating part was troubleshooting the problem when my phone line has an intermittent fault – dumping my ADSL connection – frequently.

This may be a case of telling people how to suck eggs, but if you haven’t had the joy then this may save your some time: Don’t assume a script will behave identically when you run it in the Script Tool vs. Deploying it to the server!

Recently I posted about an update to Programmatically Scrolling through ListViews.
The script worked perfectly running it in the Scripting Tool built in to Smart Office, however as soon as I deployed it to the server it wouldn’t work. And so begins the trials!

But first, there are some other bits and pieces that I had work through first…

Deploying Scripts:

  • I had been told that when deploying scripts, you needed to restart the LSO Server – seemed a little strange and the documentation was a little on the vague side
  • The Scripting Clear Cache didn’t ‘seem’ to be consistent

Restarting the LSO Server doesn’t seem to be a requirement – typically a simple clear cache and copying the updated script to the publish directory was enough (though I did seem to experience the odd issue), though the most consistent way I could ensure that my updated troubleshooting script was updated was by changing the class name. So in the case of the article above, I simply appended the iteration (eg. PMS050_B_SendKey_001) to the end of the class and saved it as a new file, copied the file to the jscript directory loaded the Smart Office Client and when I ran PMS050 it would load and compile the script. Yup, 100% client side. To quote the documentation:

If a new version of a script is deployed to the MNE server, Lawson Smart Office must be restarted to load the new version of the script. If a script with compilation errors is loaded by Lawson Smart Office, it will be marked as faulty and no further attempts will be made to execute it. When a corrected version has been deployed all running Lawson Smart Office clients must be restarted to load the updated script.” – I think that the underlined section (my emphasis) is where the person who told me to restart the server got muddled, but still, it could be clarified – maybe a diagrammed section on the specifics on what happens when a script is loaded against a panel, and the events and order they can be expected in – how and where the scripts are cached 😉

Incidentally, if you set Smart Office to log debug events (Show -> Lawson Smart Office -> General -> Log Level), then you can see when the client downloads the script. The location C:\Users\Scott\AppData\Local\Apps\2.0\Data\94YJYYY0.CVY\R3XJN15K.GRH\http..tion_3eefdc12643b7dbb_0009.0001_0654d9605bc969c8\Data\LawsonClient.log (where the later sections will probably be different on your computer, the former will probably be different too), you’ll see a line something like:
2011-01-05 20:09:21,335 [Mango.Main] INFO Mango.UI.Script.ScriptManager.LoadScript – Loaded script from url http://<servername>:81/mne/jscript//PMS050_B_SendKey_V3_026.js
Very handy when you are trying to determine if your script has been loaded.

So, it was around the 20th iteration (yes, took that long!) that I finally discovered the source of my woes with the scrolling script for PMS050, it turns out that the the OnRequestCompleted() event was being unsubscribed when the panel loaded, so the Init() method was called and then an event that fired the OnRequestedCompleted() method occurred that wasn’t a PageDown, this meant that the OnRequestedCompleted() event was then unsubscribed from.

To illustrate the difference between the published script vs. running from the Script Tool I have a quick little script which will display a MessageBox when the RequestCompleted event is fired.

import System;
import System.Windows;
import System.Windows.Controls;
import MForms;

package MForms.JScript
    class RequestTest
      public function Init(element: Object, args: Object, controller : Object, debug : Object)
       var content : Object = controller.RenderEngine.Content;

       // subscribe to our event

      public function OnRequestCompleted(sender: Object, e: RequestEventArgs)
       // display a messagebox with the event name
       MessageBox.Show("OnRequestCompleted(): " + e.CommandType.ToString());

Compile and then Run this from the Script Tool against say OIS300, you won’t see a MessageBox appear. Deploy the script to your server and then attach it to say OIS300 again. When you run OIS300, immediately after the Window appears you’ll get a MessageBox.

If the Sorting Order or Inquiry Type is changed you’ll get a KEY CommandType.

If either of these happened my event would be unsubscribed 😦 (that teaches me for blindly copying code :-))

It is a little disappointing that the behaviour here is different between the Script Tool and actually deploying it to the server. It makes it very difficult to debug issues. I suspect that simulating those events were simply overlooked when Lawson created the Scripting Tool and now they would be difficult to add.

Wouldn’t it be nice if the Scripting Tool actually had the option to launch the program that you were coding against – then you’d actually see the behaviour before you deploy it in to an environment which is challenging to debug? Maybe time to request an enhancement, I doubt that in this case I will have much luck logging the issue in CASE.

Anyway, I hope that this will save some people a few hours of frustration.

And for those that are interested – with my programmatically scrolling through the ListView, I ended up removing the remove_RequestCompleted from the OnRequestCompleted() method and added it instead to when one of my controls gets destroyed.


This entry was posted in M3 / MoveX. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s