Tools to develop Smart Office Scripts

I often get the question about which tool do I use to develop Scripts for Lawson Smart Office. Here’s my list of tools.

Smart Office Script Tool

The Smart Office Script Tool comes with all installations of Smart Office and can be run with mforms://jscript. It is basically the only tool you need to develop Scripts for Smart Office. It creates a simple JScript.NET source code template (File > New), it shows the list of current Elements with their Name, Control Type, position, and value, it has syntax coloring, it can hook to an External Editor, you can play with the Arguments, it has a debug console, and most importantly it has the Compile and Run buttons.

Here is a screenshot of a template script compiled and run:

Notepad++

I use Notepad++ for most everything text editing; it’s my vi. It has syntax coloring for JavaScript (which is close enough to JScript.NET) and C#. I hook it to the Script Tool (Script Tool > Script > Use external editor). Also, I use Notepad++ Plugin Manager (Plugins menu) to add the TextFX, Compare, XML/HTML, and HEX plugins.

Here is a screenshot of a simple script in Notepad++:

Sublime Text

I also started using Sublime Text 2 as an alternate text editor. I like the more readable syntax coloring, and the Minimap on the right.

Here is a screenshot of a simple script in Sublime Text 2:

Smart Office SDK

The Smart Office SDK is the premier source of information. We can see the official public interface, descriptive comments, and we can search for classes and members. Right now it’s only available to Infor employees and select partners.

.NET Reflector

Red Gate Software .NET Reflector is a MUST for any .NET development. I strongly recommend it. You can search for a Type, get the Class hierarchy, Analyze a Class, and the best is that you can disassemble the binary.

The Standard $35 version is enough for my needs. You will get the most value if you load the DLLs from Smart Office. The folder that contains the DLLs can be found with Smart Office > Help > About Lawson Smart Office > View log file. Then you have to go up and down the folder structure to find all the DLLs, or do a Search. The folder names have an ID that’s different on each Smart Office installation. On my laptop the paths are:

C:\Users\12229\AppData\Local\Apps\2.0\Data\79O176HR.9E2\N43AOMBD.0HB\http..tion_689b45b5b21234e1_0009.0001_46f64bcdec4dff2a\Data\
C:\Users\12229\AppData\Local\Apps\2.0\3YDTAV5W.D33\Q01ZYJYT.RW0\http..tion_689b45b5b21234e1_0009.0001_46f64bcdec4dff2a\

Import the Smart Office DLLs into .NET Reflector (File > Open Assembly) and start introspecting Smart Office. You can start with Mango.Core.dll, Mango.UI.dll, and MForms.dll. You can even make separate lists (File > Open Assembly List) of the different DLLs from the different versions of Smart Office.

Here is a screenshot of the Class for a B panel ListRow:

Microsoft .NET Framework Class Library

I refer extensively to Microsoft’s MSDN .NET Framework Class Library. When I need the API reference for a control (for example a TextBox) I just Google the following:

C# TextBox Class System.Windows.Controls site:microsoft.com

You will get the Inheritance Hierarchy, Syntax, Constructors, Properties, Methods, Events, Fields, and Examples.

Here is a screenshot of the TextBox Class:

Inspect

The Microsoft Windows SDK provides the great Inspect tool to dynamically introspect a program. You can start if from Windows > Start > Programs > Microsoft Windows SDK > Tools > Inspect Object. You can point and click at any element of Smart Office and the Inspect tool will show you the control’s Name, Type, Value, place in the Object tree, siblings, etc.

Here is a screenshot of the Inspect Tool highlighting in a yellow box a ListRow of a B panel:

UISpy

I have also used Microsoft UISpy but I changed laptops and I haven’t re-installed it yet.

Accessible Event Watcher

I have also used Microsoft Windows SDK Accessible Event Watcher (AccEvent). You can start it from Windows > Start > Programs > Microsoft Windows SDK > Tools > Accessible Event Watcher.

Here is a screenshot of AccEvent listening to my Smart Office clicks:

Microsoft C# Express

Sometimes I use Microsoft Visual C# 2010 Express . It doesn’t have support for JScript.NET but I can create compiled C# Scripts, for its IntelliSense autocompletion, and for the step by step debug options.

Here is a screenshot of a compiled Smart Office Script in C#:

Microsoft JScript.NET compiler

Sometimes I use jsc.exe to compile Scripts from the command line, outside of Smart Office. You need to reference various .NET paths. I have these ones in my laptop:

C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
C:\WINDOWS\Microsoft.NET\Framework\v3.0\
C:\WINDOWS\Microsoft.NET\Framework\v3.5\
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\

Also, you can compile Smart Office Scripts from the command line if you reference the Smart Office DLL paths (see the .NET Reflector chapter above). They won’t always execute correctly as they will be missing the dynamic context of Smart Office.

Also, you can even reference a specific DLL like this:

jsc.exe /reference:Interop.SKYPE4COMLib.dll Test.js

Here is a screenshot that shows Hello World! from a Smart Office Script in JScript.NET compiled at the command line (note the extra print statement at the bottom):

Fiddler

Microsoft’s Fiddler tool is your HTTP best friend. It will capture HTTP traffic between Smart Office and M3. It will even capture and decrypt Smart Office’s encrypted traffic. For example, press F5 in CRS610/B to refresh the panel and you will see the HTTP Request to the MvxMCSvt servlet with all the values of the panel. Or for example, create a Script that makes an M3 API call and you will see the HTTP Request to MIAccess with all the Input and Output parameters. It’s fantastic for debugging!

Here is a screenshot that shows CRS610/B displaying a record:

Snoop

Snoop is another great WPF spying utility like the Inspect tool of the Microsoft Windows SDK.

Snoop also shows the 3D breakdown of how the controls are visually rendered hierarchically on the screen:

JetBrains

dotPeek is a free-of-charge .NET decompiler from JetBrains that can be used like Red Gate Reflector.

Disclaimer

The opinions expressed in this blog are my personal opinions only, and not those of Lawson nor Infor. By using recommendations from this blog your code might break with upgrades of Smart Office. To ensure your code won’t break, use only the Smart Office API which you can find in the Smart Office Developer’s Guide.

UPDATE 2012-04-24: Added paragraphs for Sublime Text 2, and Smart Office SDK.

UPDATE 2012-07-12: Added paragraphs for JetBrains .NET decompiler, and Snoop the WPF spy utility, following Karinpb‘s recommendation.

Published by

thibaudatwork

M3 Technical Consultant

9 thoughts on “Tools to develop Smart Office Scripts”

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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