Business central blog
Subscribe to blog and get news about new posts.

Unique ShortCutKey for Actons: Return

ShortCutKey is a fairly well-known property for actions in Business Central. But did you know about such a unique ShortCutKey as Return? Let's talk about it.

Return

The ShortCutKey property for actions allows to assign keyboard keys. Besides this, there is a list of reserved keys that are better not to use. But what interests us is such a key as Return. Interestingly, Return and Enter are historically different keys; here is an example of an Apple keyboard where both keys are present.
Apple M0110A
But let's get back to the uniqueness of the Return ShortCutKey in Business Central. Let's try to assign this shortcut to an action on page list, something like this:

actions
{
  area(Processing)
  {
    action(SomeAction)
    {
      ApplicationArea = All;
      InFooterBar = true;
      Image = AmountByPeriod;
      Caption = 'Some Action';
      ToolTip = 'Some Action';
      ShortcutKey = Return;
      trigger OnAction()
      begin
        Message('RecordId is %1', Rec.RecordId());
      end;
    }
  }
  area(Promoted)
  {
    actionref(SomeAction_Promoted; SomeAction)
    {

    }
  }
}
When the page is in non-editable mode, the first field will become clickable, and clicking on it will trigger our Action!
Also, by double-clicking on a line or any field, we will also trigger the Action, which can be quite convenient.
One of the interesting uses is to call different Page Cards based on conditions. Essentially, you could write a function that replaces the CardPageId property but supports conditions. The pseudocode on the list pages might look like this:

action(SomeAction)
{
  ApplicationArea = All;
  InFooterBar = true;
  Image = AmountByPeriod;
  Caption = 'Some Action';
  ToolTip = 'Some Action';
  ShortcutKey = Return;
  trigger OnAction()
  var
    Condition1, Condition2 : Boolean;
  begin
    case true of
      Condition1:
        Page.Run(100500, Rec);
      Condition2:
        Page.Run(7777, Rec);
      else
        Page.Run(0000, Rec);
    end;
  end;
}
What other interesting ShortCutKeys do you know? I suggest you try this :)

ShortcutKey = 'Shift+k';
April 30, 2024