Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

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

(1) ShareShare
ReportReport
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;
 
    layout
    {
        area(content)
        {
            field(AccountNo; /No./)
            {
                Caption = 'Account No';
            }
        }
    }
 
    trigger OnInsertRecord(BelowxRec: Boolean): Boolean
    var
        GLAccount: Record /G/L Account/;
    begin
        GLAccount.Init();
        GLAccount./No./ := AccountNo;
 
        // Set other fields as needed
        GLAccount.Insert();
    end;
 
    trigger OnModifyRecord(): Boolean
    begin
         // Handle modifications if necessary
    end;
 
    trigger OnDeleteRecord(): Boolean
    begin
         // Handle deletions if necessary
    end;
}
 
Does anyone knows how to proceed?
  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 75,561 Super User 2024 Season 2 on at
    Issue with Alphanumeric Field Naming in API Page for "G/L Account" in Business Central
    It is recommended that you do not use No., but use the system id. This is also standard practice.
    The following is the standard API of G/L Account. Hope it can give you some reference.
     
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans