Skip to main content

Issue with Alphanumeric Field Naming in API Page for "G/L Account" in Business Central

editSubscribe (0) ShareShare
Posted on by 3
Hi All,
I am experiencing a challenge while developing a custom API page in AL for Business Central. My API page is designed to interact with the /G/L Account/ table, specifically to import records.

Issue: I am using the field /No./ from the /G/L Account/ table as the primary key in my API page. However, I encounter a conflict between two requirements:
ALAL0528 Warning: Fields in API pages must be alphanumeric.
ALAL0615 Warning: Fields specified in ODataKeyFields must be used as the source expression in a page control.

This presents a problem because the field /No./ is not alphanumeric, but it needs to be directly used to satisfy the ODataKeyFields requirement. I attempted using an alphanumeric alias in the layout while maintaining the original field name in the ODataKeyFields, but this leads to the ALAL0615 warning.

Could you please provide guidance or a solution on how to handle this situation? I need to ensure that my API page adheres to the best practices and requirements of AL development while correctly interfacing with the /G/L Account/ table.

sample code where I tried to use an alias as explained.
page 50101 /GL Account Import API/
    PageType = API;
    Caption = 'GL Account API';
    UsageCategory = Administration;
    APIPublisher = 'myCompany';
    APIGroup = 'myGroup';
    APIVersion = 'v1.0';
    EntityName = 'glaccount';
    EntitySetName = 'glaccounts';
    SourceTable = /G/L Account/;
    DelayedInsert = true;
    ODataKeyFields = /No./;
    AccessByPermission = TableData /G/L Account/ = rimd;
            field(AccountNo; /No./)
                Caption = 'Account No';
    trigger OnInsertRecord(BelowxRec: Boolean): Boolean
        GLAccount: Record /G/L Account/;
        GLAccount./No./ := AccountNo;
        // Set other fields as needed
    trigger OnModifyRecord(): Boolean
         // Handle modifications if necessary
    trigger OnDeleteRecord(): Boolean
         // Handle deletions if necessary
Does anyone knows how to proceed?