Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

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

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?
Categories:
  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 69,639 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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans