Showing posts with label Mforms. Show all posts
Showing posts with label Mforms. Show all posts

Tuesday, January 10, 2012

JScripts and toolbox programs


Thibaud has posted a entry on how JScripts that can be programmed to be generic across multiple screens.  This reminded me of a solution I've used for dealing with M3 toolbox screens where the columns can change based on the panel version selected by the user.

Columns in LSO can be queried by looking at the controller.RenderEngine.ListControl.Columns list.  The following JScript parses through the list of columns (in my case in mms080) to find the columns that store the ORCA (order category) and RIDN (order number) columns.

   var category_column = 100;
   var orderno_column = 100;
   var listControl = controller.RenderEngine.ListControl;
   var columns = listControl.Columns;
   for(var i=0; i < columns.Count; i++) {
      if(columns[i] == "ORCA") { category_column = i;}
      if(columns[i] == "RIDN") { orderno_column = i;}
   }


From there I can check to see if I have the columns I need to run my JScript logic, and if I do not then advise the user accordingly.

   if (qty_column != 100 && category_column != 100') {
      //apply logic
   } else {
      //advise the user that we don't have the required information to run the script
   }

This approach allows robust JScripts that work with user-configurable toolbox screens.

Saturday, January 7, 2012

Screen design changes using JScript

I continue to be impressed with what can be achieved with JScript and LSO. The other day I wanted to improve the readability of a screen. Using personalisations I hid unnecessary fields, but I was then left with fields scattered across a screen that I wanted to group together. JScript allows me to find controls on the screen and move these around with the Grid.SetColumn and Grid.SetRow functions:

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

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

         //Find the control we want to move
         var textBoxItem = ScriptUtil.FindChild(content, "MMITNO");

         //Specify where we want to move the control to
         Grid.SetColumn(textBoxItem, 50);
         Grid.SetRow(textBoxItem, 1);

      }
   }
}
Prior to running this script the screen looks like this:

After running the script the Item number field has been moved:


Combined with the ability to set the Tab Order in LSO we're able to create streamlined panels that show just the information we're interested in, and group them together into business or user-specific groupings.

Monday, September 5, 2011

New LSO jscript / mashups blog

Karin has started blogging on LSO jscript and mashup development over at lawsonsmartoffice.wordpress.com.  I've been using the new jscript & API functionality from the May 2011 M3 10.1 heartbeat release for a couple of months now that is mentioned in the latest post, but I hadn't picked up on the ability to limit the fields returned from an API call to jscript.  Thanks Karin for the pointer!  This will significantly speed up a couple of jscripts that were beginning to get a little slow.

Tuesday, November 24, 2009

Smart Client / Smart Office scripting


With SmartClient Lawson introduced powerful extensibility through Mforms scripting.  This is documented in "Lawson Smart Office and Lawson Smart Client MForms Developers Guide" available from their knowledge base.

Smart Client / Smart Office functionality is exposed through the javascript language and APIs.

A couple of examples of how I've made use of this functionality: 


Create connections between programs that do not exist in the related options menu.  For example after performing a stock adjustment in MMS100 we needed to print a lot label with the current stock balance.  I added a button to MMS101 "Print Label" which called MMS235 Lot/Serial.Open, passed in the Item number and lot number and then chose Related Options, Print Label.  This brought the functionality available within M3 into a workflow that made operational sense.


Perform multiple tasks quickly.  For example in PMS100 we wanted to change all the MOs in a Schedule to reflect changes in expected manufacturing completion dates.  I added a "Reschedule" button and a text box for the new date then scripted a loop which parsed through all the MOs listed and added a new entry in PMS010 MO Reschedule for each item in the list.  This allowed the staff member to easily update the finish dates on large numbers of MOs, ensuring the Material Plan for these items was correct and allowing shortages to be easily identified.

Once scripts are developed these are deployed easily by placing them in the appropriate directory on the Smart Client / Smart Office websphere server and attaching the script to a program either on a per-user basis or via a template to all users.

Mforms scripting is undoubtedly a powerful capability added to the Lawson toolset.  The documentation provided by Lawson could however do with more worked examples and the details on the APIs provided is quite limited.