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.

No comments:

Post a Comment