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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Switch Companies in AL And Append to a Table

(1) ShareShare
ReportReport
Posted on by 4
I am trying to create a table in my AL code and BC which displays the entire inventory of one of my companies, it shows various records regarding each inventory item. However, I have multiple companies and want to display the inventory of all the companies.
 
In the code I am able to switch companies and able to display what company I am on, but I am unsure on how to append new items to the existing table which belongs to the other companies. So far, the inventory only displays all the products from Company 1, however I need to append all the items in Company 2's inventory and show it all in one table.
 
page 60100 BIRemainingItemQuantity
{
    ApplicationArea = All;
    Caption = 'Remaining Item Quantity';
    PageType = List;
    SourceTable = /Item Ledger Entry/;
    Permissions = tabledata /Item Ledger Entry/ = R;
    DataCaptionFields = /Entry No./;
    UsageCategory = History;
    DeleteAllowed = false;
    ModifyAllowed = false;
    InsertAllowed = false;
 
    layout
    {
        area(content)
        {
            repeater(General)
            {
                //Company name variable will be extracted from a third party Company object
                field(/Entity/; CompanyName)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the Company/Entity in which the item belongs to.';
                }
 
                field(/Item No./; Rec./Item No./)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the item number or UID for that item.';
                }
 
                field(/Location Code/; Rec./Location Code/)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the code for the location that the entry is linked to.';
                }
 
                field(/Variant Code/; Rec./Variant Code/)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the Variant Code.';
                }
 
                field(/Remaining Quantity/; Rec./Remaining Quantity/)
                {
                    ApplicationArea = All;
                    ToolTip = 'Specifies the quantity in the Quantity field that remains to be processed.';
                }
            }
        }
    }
 
    trigger OnOpenPage();
    var
        //Fetch company record
        Company: Record /Company Information/;
        //Define company name variable
        CompanyName: Text;
    begin
        Rec.SetFilter(/Remaining Quantity/, '<>%1', 0);
        if Company.Get() then
            Message('Current Company /%1/', Company.Name);
        Company.ChangeCompany('Company 2');
        //Add extra records.....
        //Switch Again
        Rec.ChangeCompany('Company 1');
        if Company.Get() then
            Message('Switched To/%1/', Company.Name);
 
       
    end;
 
    trigger OnAfterGetRecord()
    //On Each Record, Embed a new field which displays the company name
    var
        //Fetch company record
        Company: Record /Company Information/;
        //Define company name variable
        CompanyName: Text;
    begin
        //Assign the CompanyName variable to the Company Name which is fetched from the Company object
        if Company.Get() then
            CompanyName := Company.Name;
    end;
}
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at
    Hi, hope the following helps.
    Collect data from different companies and Drilldown into the data of another company
     
    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,028 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,366 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,175 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans