Create the customer list page extension object

Completed

For this scenario, you'll add an action on the Customer List page. This action should open the list of reward levels.

In Business Central, actions are displayed at the top of each page, often referred to as the action bar. Each page has a different set of actions, depending on the page type, and the processes that the page supports. To create the appropriate set of actions for a page, you should have a good understanding of your customer's business processes.

The following page extension object extends the Customer List page object by adding one action control, Reward Levels, to the Customer group on the page.

pageextension 50101 CustomerList extends "Customer List"
{
    actions
    {
        addfirst("&Customer")
        {
            action("Reward Levels")
            {
                ApplicationArea = All;
                Image = CustomerRating;
                Promoted = true;
                PromotedCategory = Process;
                PromotedIsBig = true;
                ToolTip = 'Open the list of reward levels.';

                trigger OnAction();
                var
                    CustomerRewardsExtMgt: Codeunit "Customer Rewards Ext Mgt";
                begin
                    if CustomerRewardsExtMgt.IsCustomerRewardsActivated then
                        CustomerRewardsExtMgt.OpenRewardsLevelPage
                    else
                        CustomerRewardsExtMgt.OpenCustomerRewardsWizard;
                end;
            }
        }
    }
} 

The Image property specifies the icon that you want to associate with an action. Business Central includes images that you can use on actions in command bar menus and promoted actions on the ribbon. To add an image to an action, add the Image property and then provide the name of the image that you want to use from the Business Central Action Icon Library. By default, the size of images is 16 pixels high by 16 pixels wide. For promoted actions, you can choose to display larger images that are 32 pixels high and 32 pixels wide.

The Promoted property indicates whether the selected action is promoted, which means that it's elevated to a promoted category in the action bar and in the group where is it defined. This feature allows you to make a copy of an action and place it on the action bar where it's easier to find. Promoted actions are actions that are set up on the Actions, Navigate, or Report menus in the action bar, but are also configured to display on the Home tab. Though the actions are set up on the Actions, Navigate, or Report menus, you can choose to hide them on these menus and only show them on the Home tab.

The PromotedCategory property sets a category for a promoted action. Promoted actions appear in the action bar on a page. You can promote an action by setting the Promoted property. Categories allow you to group similar actions under a common caption.

You can choose between 20 categories:

  • New Actions will appear in the New menu.

  • Process Actions will appear in the Process menu.

  • Report Actions will appear in the Report menu.

  • Category4 Actions will appear in the Category 4 menu.

  • Category5 Actions will appear in the Category 5 menu.

  • Category6 Actions will appear in the Category 6 menu.

  • Category7 Actions will appear in the Category 7 menu.

  • Category8 Actions will appear in the Category 8 menu.

  • Category9 Actions will appear in the Category 9 menu.

  • Category10 Actions will appear in the Category 10 menu.

  • Category11 Actions will appear in the Category 11 menu.

  • Category12 Actions will appear in the Category 12 menu.

  • Category13 Actions will appear in the Category 13 menu.

  • Category14 Actions will appear in the Category 14 menu.

  • Category15 Actions will appear in the Category 15 menu.

  • Category16 Actions will appear in the Category 16 menu.

  • Category17 Actions will appear in the Category 17 menu.

  • Category18 Actions will appear in the Category 18 menu.

  • Category19 Actions will appear in the Category 19 menu.

  • Category20 Actions will appear in the Category 20 menu.

By default, the category names are used as the captions in the ribbon. These category names correspond to the captions that are displayed for the category on the page in Business Central. Likely, you'll want to change the captions, especially Category4 through Category10.

The PromotedIsBig property sets a value that indicates whether to display the action before other actions in the action bar, regardless of its position in the AL page definition. If more than one action has the PromotedIsBig property set to true, then the actions will appear before other actions in the order that they're defined in AL.

For this example, you'll use the OnAction trigger. This trigger runs when a user selects an action on the page.

trigger OnAction();
var
CustomerRewardsExtMgt: Codeunit "Customer Rewards Ext Mgt";
begin
if CustomerRewardsExtMgt.IsCustomerRewardsActivated then
CustomerRewardsExtMgt.OpenRewardsLevelPage
else
CustomerRewardsExtMgt.OpenCustomerRewardsWizard;
end;  

The code verifies if the customer rewards extension has been activated and, if so, it will open the Rewards Level page. If the customer rewards extension hasn't been activated, you'll need to run the customer rewards wizard page, which will be created in a later module of this learning path.