Create the Rewards Level List page object

Completed

The following code adds the 50101 Rewards Level List page that enables the user to view, edit, or add new reward levels and their corresponding minimum required points. The code example includes tooltips for controls and a relative link to context-sensitive Help.

Note

Later in this module there is an exercise where you can create this object, following step by step instructions.

page 50101 "Rewards Level List"
{ 
    PageType = List;
    ContextSensitiveHelpPage = 'sales-rewards';
    SourceTable = "Reward Level";
    SourceTableView = sorting ("Minimum Reward Points") order(ascending);

    layout
    {
        area(content)
        {
            repeater(Group)
            {
                field(Level; Level)
                {
                    ApplicationArea = All;
                    Tooltip = 'Specifies the level of reward that the customer has at this point.';
                }

                field("Minimum Reward Points"; "Minimum Reward Points")
                {
                    ApplicationArea = All;
                    Tooltip = 'Specifies the number of points that customers must have to reach this level.';
                }
            }
        }
    }

    trigger OnOpenPage(); 
    begin 

        if not CustomerRewardsExtMgt.IsCustomerRewardsActivated then 
            Error(NotActivatedTxt); 
    end; 

    var 
        CustomerRewardsExtMgt: Codeunit "Customer Rewards Ext. Mgt."; 
        NotActivatedTxt: Label 'Customer Rewards is not activated'; 
}

Make sure that you save the object by using the Ctrl+S shortcut keys. (You won't be able to successfully compile this until you complete everything in this module.)

The structure of a page is hierarchical and breaks down into three sections:

  • Metadata section - The first block of code contains metadata for the overall page:

    • Page type

    • Source table from which the page is showing data

    • Rewards Level List page, which contains a number, name, and several properties (for example)

          page 50101 "Rewards Level List"
          { 
          	PageType = List;
          	SourceTable = "Reward Level";
          	SourceTableView = sorting ("Minimum Reward Points") order(ascending);
          	ApplicationArea = All;
          	UsageCategory = Lists; 
      
  • Layout section - The second section describes the page layout:

    • Visual parts - This portion of code shows the visual parts on the page.

      The following example shows the layout section of the Rewards Level List page.

        	layout
        	{
        		area(content)
        		{
        			repeater(Group)
        			{
        				field(Level; Level)
        				{
        					ApplicationArea = All;
        					Tooltip = 'Specifies the level of reward that the customer has at this point.';
        				}
      
        				field("Minimum Reward Points"; "Minimum Reward Points")
        				{
        					ApplicationArea = All;
        					Tooltip = 'Specifies the number of points that customers must have to reach this level.';
        				}
        			}
        		}
        	} 
      
    • Control tooltips - According to the user assistance model for Business Central, apps are expected to apply tooltips to controls on pages. In the client, tooltips appear when you point to the caption of the control. The default is an empty string, which means that no tooltip is offered. In the preceding example, the Tooltip property has been set for the fields in the page.

    • Application areas - The ApplicationArea property sets the application areas that apply to the control. Application areas represent a feature in the system that offers developers, administrators, and users the ability to define differentiated user experiences. The areas are mapped to controls to show or hide them on page objects to enable more or fewer business scenarios. An application area tag must have the format name, where name is the application area. The name can be any combination of letters (Aa-Zz) and numbers (0-9) without spaces.

      For example, to specify the Basic and Fixed Assets application areas, set the property to Basic, FixedAssets. If the control applies to all application areas, you can set the property to All, which means that the control will always appear in the user interface. If one or more application areas are enabled in a session, any controls that aren't tagged with an application area won't appear in the user interface.

    • Discoverable pages or reports - The UsageCategory property is a required setting that is used together with the ApplicationArea property. You can enable a page or report to be discoverable through the Tell me feature in Business Central by using the UsageCategory property.

      If the UsageCategory is set to None, or if you don't specify a UsageCategory:

      • The page or report won't show up when you use the search functionality.

      • Users won't be able to bookmark a link to the page or report object from the user interface.

  • Published actions section - The third section details the actions that are published on the page. In the Rewards Level List page, you haven't defined custom actions.