Create the Customer Rewards Management Setup table object

Completed

The Customer Rewards Mgt. Setup table is used for storing information about the codeunit that should be used to handle events in the extension. This table will enable you to create mock events in your sample test. The table consists of two fields:

  • Primary Key

  • Cust. Rew. Ext. Mgt. Cod. ID

Note

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

Create a new file with the name CustomerRewardsMgtSetup.Table.al. Paste the following code in the file to create the table definition.

table 50102 "Customer Rewards Mgt. Setup"
{
    Caption = 'Customer Rewards Mgt. Setup';
    DataClassification = CustomerContent;
    
    fields
    {
        field(1; "Primary Key"; Code[10])
        {
            Caption = 'Primary Key';
            DataClassification = CustomerContent;
        }

        field(2; "Cust. Rew. Ext. Mgt. Cod. ID"; Integer)
        {
            Caption = 'Customer Rewards Ext. Mgt. Codeunit ID';
            DataClassification = CustomerContent;
            TableRelation = "CodeUnit Metadata".ID;
        }
    }

    keys
    {
        key(PK; "Primary Key")
        {
            Clustered = true;
        }
    }
}

Make sure that you save the object by using the Ctrl+S shortcut keys.

The table will show an example of a table relation.

TableRelation = "CodeUnit Metadata".ID;

The TableRelation property lets you establish lookups into other tables.

Because the object the TableRelation links to doesn't exist yet, the compiler will show an error on this line. To remove the error, temporarily, you can comment out the TableRelation, like for example:

//TableRelation = "CodeUnit Metadata".ID; 

Example – Use the TableRelation property

On the Customer Rewards Mgt. Setup wizard page (that you'll create later), you want to select a codeunit that handles a certain piece of business logic. You can accomplish this task by using a table relationship.

You'll use this field to store the codeunit that needs to handle the business logic for your extension. This method is a typical way that you can enhance your extension by adding another extension to it. The other extension might be one that you develop, or it could be an extension that is developed by another company.

The activation of the customer rewards extension can happen through an external request or, to be more precise, a web service. To avoid overcomplicating this example, your code will be mock-up code without external web service requests.

This scenario is a good example of building an extension that is flexible and extendable. If you're a value-added reseller (VAR), this example would be of interest to you because it shows how to give your partners and customers the ability to build further on the functionality that you deliver.