Script for Locating an Entry in a Subfile/Browselist

RAMP-NL

Script for Locating an Entry in a Subfile/Browselist


This script  locates an entry in a browse list.

The position of the entry in the list is determined by the value entered in an input field. Then, perform an action on the selected the entry.

In this script:

·         utxtEmpno is the name given to the field to position to in the form using newlook Designer

·         uDataGrid Is the name given to the browselist/subfile in the form using newlook Designer

·          The first column in the data grid contains the Option field.

·          The second column in the data grid contains the value to position to.

·          The VisualID1 of the Instance List has the employee number

·          Use option 2 to change the details of an employee selected in the Instance List.

/* Set the value of a variable to that of the selected Employee */

var strCompare = objListManager.VisualId1[0];

/* Set the value of the field in the form to that of the selected Employee */

SETVALUE("utxtEmpno", strCompare);

/* Send an Enter key to cause the list positioning */

SENDKEY(KeyEnter);

/* Get the number of rows in the data grid */

var intRowCount = GETVALUE("uDataGrid.RowCount");

/* Traverse the rows and compare the value of the second column with the one to position to. */

for (var intRowNo = 0; intRowNo < intRowCount; intRowNo++)

{

if ( GETVALUE("uDataGrid.Rows(" + intRowNo + ").Cells(1).Text") == strCompare)

   {

   /* Type a 2 next to the first entry and press enter */

      SETVALUE("uDataGrid.Rows(" + intRowNo + ").Cells(0).Text", 2);

      SENDKEY(KeyEnter);

      break;

   }

}