Navigate Portal Rows up/down from a specific field

I received a request from a customer for faster data entry. They asked if they could navigate the portal using arrow keys. But, there was a twist! They wanted to move up/down from a specific field.

As a rule, any given order can have upwards of 10+ of the same item. They would start by creating x number of portal rows. Then populate the Style # for each entry followed by color for each entry then size and qty.

Enter Get ( TriggerKeystroke )

This function returns a string that contains the characters typed that activated an OnObjectKeystroke or OnLayoutKeystroke script trigger. Get ( TriggerKeystroke ) need to be combined with Code() function to evaluate the keystroke.

Code () - returns the Unicode for the keystroke typed. There is a table of common keys in FM Pro documentation.

As this is going to be triggered from a field OnObjectKeystroke is the only choice.

I also wanted to make the script modular. The user would be start in the field so I used Get ( ActiveFieldName ) as the script Parameter. The field needs an object name so I used the name returned by Get ( ActiveFieldName).

The Script!!

   Set Variable [ $$Prow; Value: Get ( ActivePortalRowNumber )]
    If [ Code ( Get ( TriggerKeystroke )) = 29 //code for up arrow]
          If [ Get ( ActivePortalRow ) = 1 //if first portal row don’t go up]
             Exit Script[]
          End If
          Go To Portal Row [ Select; Previous ]
          Go To Object [ Object Name: Get (ScriptParameter )]
     Else If [ Code ( Get ( TriggerKeystroke )) = 31 //code for arrow down]
          If [ $$Prow = Count ( Orders_OrderLI|OrderID::zConstant1 ) //if last portal row don't go down]
             Exit Script[]
          End If
          Go To Portal Row [ Select; Next ]
          Go To Object [ Object Name: Get (ScriptParameter )]
     End If

To use this script for the next field all I had to do was setup the Script Trigger and send Get ( ActiveFieldName ) as the parameter. Done!!

Demo DB