Skip to content Skip to sidebar Skip to footer

Not Able To Shift Focus To Shipment Nbr Field On Shipments Screen

I'm using the built in Acumatica browser commands to insert a new shipment record by pressing a function key. The function Key triggers the command with px.searchFrame(window.top,'

Solution 1:

The Acumatica Framework provides built-in support for keyboard shortcuts via the following properties defined in PXButtonAttribute:

  • ShortcutShift = true/false : Determines Shift key presence
  • ShortcutCtrl = true/false : Determines Control key presence
  • ShortcutChar = ‘x’ : Determines shortcut character

Below is the sample to insert new Shipment when the user presses F2. Since the code snippet below utilizes capabilities of the framework, by pressing F2 the user executes the Insert command from the SOShipmentEntry BLC instead of simulating button click in JavaScript. This approach guarantees that all logic embedded into the Insert command, including setting focus to the Shipment Nbr input, is properly executed.

publicclassSOShipmentEntryExt : PXGraphExtension<SOShipmentEntry>
{
    publicclassPXInsertShortCut<TNode> : PXInsert<TNode> where TNode : class, IBqlTable, new()
    {
        public PXInsertShortCut(PXGraph graph, string name)
        : base(graph, name)
        {
        }
        public PXInsertShortCut(PXGraph graph, Delegate handler)
            : base(graph, handler)
        {
        }
        [PXUIField(DisplayName = ActionsMessages.Insert, MapEnableRights = PXCacheRights.Insert, MapViewRights = PXCacheRights.Insert)]
        [PXInsertButton(ShortcutChar = (char)113)]
        protectedoverride IEnumerable Handler(PXAdapter adapter)
        {
            return base.Handler(adapter);
        }
    }

    public PXInsertShortCut<SOShipment> Insert;
}

Solution 2:

If you're executing a callback to the server in JavaScript, the callback return might set focus to another field after it finishes execution. Your focus() statement works but the callback return performs another focus() on a different control after yours.

Hooking the Ajax callback allows you to put your focus() statement after the Acumatica framework focus():

window.addEventListener('load', function () { px_callback.addHandler(ActionCallback); });

functionActionCallback(callbackContext) {
   px_alls["edShipmentNbr"].focus();
};

Post a Comment for "Not Able To Shift Focus To Shipment Nbr Field On Shipments Screen"