Exercise - Create the Rewards Level List page object

Completed

Scenario

The Rewards Level List page enables the user to view, edit, or add new reward levels and their corresponding minimum required points. The code example includes tooltips for controls.

Create the Rewards Level List page object

  1. Create a new al file.

    1. To create a new page in your extension, first create a new file. Select the New File button in the side bar of Visual Studio Code.

    2. Make sure that the file extension is al. In this example, you might want to use the name RewardsLevelList.Page.al.

  2. Add the code to the page. You can copy the following code and paste it in the RewardsLevelList.Page.al file.

    page 50101 "Rewards Level List"
    
    {
    	PageType = List;
    	ContextSensitiveHelpPage = 'sales-rewards';
    	SourceTable = "Reward Level";
    	SourceTableView = sorting("Minimum Reward Points") order(ascending);
    	ApplicationArea = All;
    	UsageCategory = Lists;
    
    	layout
    	{
    		area(content)
    		{
    			repeater(Group)
    			{
    				field(Level; Rec.Level)
    				{
    					ApplicationArea = All;
    					Tooltip = 'Specifies the level of reward that the customer has at this point.';
    				}
    
    				field("Minimum Reward Points"; Rec."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';
    }						
    

Note

The Customer Rewards Ext Mgt codeunit is created in a later module, so this page doesn't compile until you complete that module.