Showing posts with label JScript. Show all posts
Showing posts with label JScript. 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.