Finding a column field name in an M3 LSO list panel using a script

Ever try to find the exact field name on a list panel but none of the traditional approaches like panel view or edit view seem to give you the correct field name?

The issue I was running into is that the names of the fields that are used by the jscript only have the last 4 characters of the name. Not knowing this I kept submitting the 6 character field name that kept triggering an error of “field not found”. So I found snippet of script in the LSO Developers Guide that listed the actual field names the script sees on the active panel. I then used the field name of the desired column and voila…the script worked.

This script is particularly useful when the list panel does not have a “User” definable panel view like MMS060.

It would seem like there could have been a simpler approach or a lesson learned.

Do you have any insights to add to what I have learned? Please comment.

Here is the full script:

import System;

package MForms.JScript {
    /* You can use this section to list out the names of the columns to get the specific
    name that needs to be used in the Args variable of the Script Tool.
    */
    class PanelFieldList {
        var controller     : Object
        //var content     : Object; 
        var debug         : Object
        var listView     : Object;        
        var isDebug;

        public function Init(element: Object, args: Object, controller : Object, debug : Object) {
        try{
            // Set the member variables for later use
            this.controller     = controller;
            //this.content        = controller.RenderEngine.Content;
            this.listView         = controller.RenderEngine.ListViewControl;                        
            this.debug          = debug;        
            
            // Set debug flag in case you want Log statements
            isDebug = true;            

            var listControl = this.controller.RenderEngine.ListControl;
            var columns = listControl.Columns;            
            var columnIndex = -1;
            
            for(var i=0; i<columns.Count; i++) {
                debug.WriteLine(“Column “ + (i+1) + ” = “ + columns[i]);
            }
            var listView = listControl.ListView;
            var rowCount = listView.Items.Count;
            debug.WriteLine(“Number of rows = “ + rowCount);
                        
            }
            catch(ex: Exception){
                debug.WriteLine(“\n Exception Message: \n” + ex)
                return;
            }
            
        }

    }
}

Advertisements