Infor Technology Blog

« | Main | »

Scripting Tools for Infor Smart Office for Infor Lawson – Part 1

March 16, 2017

By Vince McGowan, Senior Principal Software Engineer

Scripting in Infor Smart Office for Infor Lawson

The ability to add Jscript to an Infor Lawson application form is one of the more powerful features of Infor Smart Office (ISO). It opens up the possibility of using the full set of functionality provided by the Microsoft .NET library of code to customize the behavior and appearance of the Infor Lawson form.

The first thing of note is that to have access to any of the scripting tools, the user’s Role settings must allow it. The default Role provided with Infor Smart Office does not allow access. To allow access, either change the default Role in the Lawson Role Manager (not recommended), or assign a specific Role to the user in Infor Lawson Resource Management (RM) and create that Role in the ISO Role Manager.

Once the user is granted access, there are 3 tools that become available:

  • Infor Lawson Script Tool
  • Infor Lawson Object Browser
  • Infor Lawson API Builder

This is the first in a series of posts that will examine each of the tools available to a script developer in Infor Smart Office. In this post we will look at the Infor Lawson Script Tool.

Infor Lawson Script Tool

The Script Tool is the main script development tool and is integrated into Infor Smart Office. It can be used to edit, compile, test and publish scripts that run in forms. It is accessed in one of multiple ways: from the Navigator widget under Infor Lawson -> Other -> Lawson Script Tool; from the Start box with ‘sforms://jscript’; or from a Favorite or Canvas shortcut.

When initially released, the Script Tool had very limited functionality and there was even a provision made for developing scripts using an external editor. Over time, however, the Lawson tool has been vastly improved and integrated with the other tools such that the recommendation now would be to not use an external editor.

Scripting for Infor Lawson is developed using Microsoft’s Jscript.NET language which is syntactically similar to JavaScript, but which allows access to all of the power of the .NET library.

The Script Tool consists of a menu, a command bar, an editor area where the script code is edited, buttons for compiling and running scripts, an output area, and a status bar.

File Menu

The file menu can be used to create new scripts, open existing scripts, or save the content of the editor area as a Jscript file.

Script Menu

The script menu can be used to compile and run scripts and to switch to an external editor. The compile and run items are just alternatives to the Compile and Run buttons.

The Use external editor option can be used to edit the file in another editor while still using the Script Tool for compiling and testing. An external editor can only be enabled if the current script has been loaded from disk or if it has been saved to disk. When the external editor is enabled the editor area in the Script Tool will become read-only. The content of the editor area will automatically be updated from disk each time the script is compiled. You would do the editing in the external editor, save the file and switch back to Script Tool to compile and test the script.

The Save Selection as Snippet and Insert Snippet features are available from the Script menu in the scripting window. These features provide a way to save script code so that it can be reused.

When script is selected in the window, select Save Selection as Snippet from the Script window. You will be prompted for a location to save. The file is saved with the ‘.jss’ extension.

When you select Insert Snippet, you are prompted to browse for the location of the snippet you want to use. When you select the snippet file, its contents are added to the current script at the insertion point.

Edit Menu

The Edit menu can be used to access the standard editing options such as Cut, Copy and Paste. Additionally, a Find and Replace dialog is available for searching for and/or replacing text. Use of regular expressions is also permitted.

Additionally, a Find and Replace dialog is available for searching for and/or replacing text. Use of regular expressions is also permitted.

Help Menu

The help menu can be used to access the following utilities:

  • Lawson Object Browser – This item opens a window that documents the supported scripting APIs and provides many script examples.
  • Lawson API Builder – This item opens the API Builder tool which can be used as an aid for developing scripts that make server calls.
  • View Published File – Lists all the script files published to the Lawson application server and from which the files can be viewed.

Command Bar

The command bar is used when you test scripts on a running a form. If multiple programs are running, one instance must be selected in the instance combo box. The instance combo box displays the program name.

When an instance has been selected the form elements will be displayed in the element combo box. The element combo box displays the element name and the type of control. The Refresh button will refresh both the instance and element combo boxes. An element selection is not typically used with Infor Lawson scripts.

The Refresh button must be used if the Script Tool was started before the programs, if programs have been closed or started, or if a new form has been loaded. The Arguments text box can be used to provide the script with arguments. Helpers are for auto-populating scripts with available functions and handlers.

Working with Helpers

Infor Smart Office script helpers are a way to automate adding functions or handlers to a script, are available from the Script Tool interface. Helpers are grouped in the following categories: IForm functions, Event handler, Utility function, and Control utilities

To use a helper:

  1. Place your cursor in the location within your script where you want to add a function or handler.
  2. Select the dropdown for the type of scripting object you are adding.
  3. From the second dropdown, select the specific helper you want to use.
  4. Click Insert.

The code for the function or handler will be automatically inserted in the editor. Then the developer simply needs to replace the placeholder parameters with the names of variables used in the script.

Editor Area

The editor area is where the script code is edited or viewed.  The size of the editor area can be increased by dragging the vertical divider line up or down.

Smart indenting

When you begin a line with a tab or leading spaces, subsequent lines added by pressing Enter will be indented the same number of spaces.


The Infor Smart Office Script Tool uses color-coding in the editor for certain Jscript keywords and .NET and ISO object names.

Code Completion

When writing script with the content editor certain Infor Lawson objects will be recognized and present a code completion list when an object name is entered followed by a period. As an item in the list is selected, a tooltip is displayed to the right. By keying the first letters of a method or property, the list is filtered down to matching items.

Object Browser Help

Integration with the Infor Lawson Object Browser is also provided. When the cursor is within a recognized Infor Lawson method or property, pressing F1 will launch the Object Browser to that method or property information.


The Compile button will compile the content in the editor area. If there are compilation errors, these will be displayed in the output area.

The Run button will run the script. If the script needs to be compiled, it will be automatically compiled when the Run button is clicked. Runtime errors will also be displayed in the output area. Run is disabled if the Instance list needs to be refreshed. If the run button is disabled, this indicates there is no running application instance selected in Instance drop down box. If you have tested against a form, closed and reopened it, you must click the Refresh button to enable the Run button.

The Publish button is for deploying the script to the Infor Lawson application server which then will be available to view and attach to forms as a personalization.

Output Area

The output area will display compilation errors and runtime errors.

If the compilation error has information about the column and row of the error, you can double-click the error message to position the cursor on the error in the editor area. Output from the script using the debug object is also displayed in the output area.

In the next post, we will look at the Infor Lawson Object Browser, the complete reference for the supported Infor Lawson scripting model.


2 responses to “Scripting Tools for Infor Smart Office for Infor Lawson – Part 1”

  1. Dominik says:

    I am using Infor M3 and SmartOffice.
    I cannot run scripting tool usign sforms://jscript but I am using mforms://jscript
    In Scripting Tool there is no help menu, there is no Object Browser, there is no API Builder and Code Completion.
    How can I turn it on ?

    • Don Peterson says:

      Hi Dominik,

      I checked with the manager of M3 Smart Office Development and here is what I got back:

      “The functionality available for M3 and Lawson are completely different. The functionality mentioned here is simply not available on M3.”

      Hope this helps.

Leave a Reply to Dominik Cancel reply

Your email address will not be published.