web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

AL API page that returns customer details as well as that customer's default dimensions

(3) ShareShare
ReportReport
Posted on by 31
I am creating essentially an extension of the default get customer endpoint, but need to return dimensions as part of the /customers endpoint, so part() won't work for me. I presume I need to do something along the lines of this:
 
var
Dimensions: Text;
 
trigger OnAfterGetRecord()
var
TDimensions: Record "Default Dimension";
begin
TDimensions.Reset();
TDimensions.Get();
Dimensions := TDimensions."Dimension Code";
end;
 
But obviously need to pass in some "query" stuff to specify what data I want, but not really sure how. Any help is much appreciated.
I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at
    Why you don't want to create part for dimensions filter for Table ID and No. for that customer to view Default Dimensions.
     
     
  • JB-20031303-0 Profile Picture
    31 on at
    I'm creating an integration layer between an internal system and business central, and need a single api endpoint to pull customer data and default dimensions, multiple requests is possible but adds a lot of complexity
  • Verified answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    Hi,
     
    You can try below code:
    trigger OnAfterGetRecord()
        var
            DefaultDimension: Record "Default Dimension";
            DimensionText: Text;
        begin
            // Clear the Dimensions variable for each customer record
            Dimensions := '';
    
            // Filter Default Dimension records for the current customer
            DefaultDimension.Reset();
            DefaultDimension.SetRange("Table ID", Database::Customer); // Table ID for Customer table
            DefaultDimension.SetRange("No.", Rec."No."); // Filter by the current customer's No.
    
            // Loop through all dimensions for the customer
            if DefaultDimension.FindSet() then begin
                repeat
                    // Append each dimension code to the text (e.g., "DEPARTMENT,PROJECT")
                    if DimensionText = '' then
                        DimensionText := DefaultDimension."Dimension Code"
                    else
                        DimensionText := DimensionText + ',' + DefaultDimension."Dimension Code";
                until DefaultDimension.Next() = 0;
            end;
    
            // Assign the concatenated dimension codes to the Dimensions field
            Dimensions := DimensionText;
        end;
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at
    Hi, This functionality is available in the standard API.
     
    But if you don't want to use it, another way to consider is to add the Default Dimension as a real field in the Customer table (Add the dimension you need to display), so that you process the data when setting the Default Dimension and do not do any processing when the API obtains it.
     
    Hope this can give you some hints.
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans