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

Switch company using CAL

(0) ShareShare
ReportReport
Posted on by 634

Hi experts,

I want to  navigate to other company using custom action on a role center page the way we do using my setting in business central online version. 

Suppose we have four companies A,B,C,D in a sandbox. The current company is A. I want to add three action for the rest of companies in a role center page So by clicking on company C for example, I should go

directly to company C from that custom action. 

 Thanks

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    What about this: github.com/.../al-companychange-dropdown

  • Suggested answer
    Rehan Satti Profile Picture
    634 on at

    I have downloaded the source code but this did not help. As I don't know much about JavaScript and control addins. I have figure it out how to do this in AL.

    I want to add an action on role center page for a specific company navigation.

    As we know that we have very limited customization option on a role center page. This is how I did it.

    pageextension 50401 BusinessManagerRC extends "Business Manager Role Center"

    {

       actions

       {

           addafter("Chart of Accounts")

           {      

               action("NavigateNorwayCompany")

               {

                   ApplicationArea = Basic, Suite;

                   CaptionML = DAN = 'Norge', ENU = 'Norway';

                   Image = Import;

                   //Visible = InnotechDK;

                   RunObject = codeunit NavigateNOC;

               }

           }

       }

    }

    Added an action on the Business Manager role center page which runs the a custom code-unit.

    codeunit 50403 "NavigateNOC"

    {

       var

           ClientTypeManagement: Codeunit "Client Type Management";

           LanguageID: Integer;

           LocaleID: Integer;

           TimeZoneID: Text[180];

           VarCompany: Text;

           NewWorkdate: Date;

           ProfileID: Code[30];

           RunningOnSaaS: Boolean;

           MyNotificationsLbl: Label 'Change when I receive notifications.';

           IsNotOnMobile: Boolean;

           CompanyDisplayName: Text[250];

           ProfileAppID: Guid;

           ProfileScope: Option System,Tenant;

           IsCompanyChanged: Boolean;

       trigger OnRun()

       begin

           NavigateCompany();

       end;

       procedure NavigateCompany()

       var

           company: Record Company;

           CurrentCompany: Text[100];

           SelectedCompany: Record Company;

           AllowedCompanies: Page "Allowed Companies";

           IsSetupInProgress: Boolean;

       begin

           if NOT (company.CurrentCompany = 'NorwayCompany') then begin

               VarCompany := 'NorwayCompany';

               SetCompanyDisplayName;

           end;

       end;

       local procedure SetCompanyDisplayName()

       var

           SelectedCompany: Record Company;

           CompanyInformationManagement: Codeunit "Company Information Mgt.";

       begin

           if SelectedCompany.Get(VarCompany) then

               CompanyDisplayName := CompanyInformationManagement.GetCompanyDisplayNameDefaulted(SelectedCompany);

           OnQueryCompanyPage();

       end;

       local procedure OnQueryCompanyPage()

       var

           AllProfile: Record "All Profile";

           TenantLicenseState: Codeunit "Tenant License State";

           UserPersonalization: Record "User Personalization";

           sessionSetting: SessionSettings;

           AnythingUpdated: Boolean;

           WasEvaluation: Boolean;

       begin

           with UserPersonalization do begin

               Get(UserSecurityId);

               if (Company <> VarCompany) or

                   IsCompanyChanged or

                  (Scope <> ProfileScope)

               then begin

                   AnythingUpdated := true;

                   sessionSetting.Init();

                   if Company <> VarCompany then begin

                       WasEvaluation := TenantLicenseState.IsEvaluationMode();

                       sessionSetting.Company := VarCompany;

                   end;

                   if ("Profile ID" <> ProfileID) or

                       ("App ID" <> ProfileAppID) or

                       (Scope <> ProfileScope)

                   then begin

                       sessionSetting.ProfileId := ProfileID;

                       sessionSetting.ProfileAppId := ProfileAppID;

                       sessionSetting.ProfileSystemScope := ProfileScope = ProfileScope::System;

                   end;

                   if "Locale ID" <> LocaleID then

                       sessionSetting.LocaleId := LocaleID;

                   if "Time Zone" <> TimeZoneID then

                       sessionSetting.Timezone := TimeZoneID;

               end;

           end;

           if AnythingUpdated then

               sessionSetting.RequestSessionUpdate(true);

       end;

    }

    I am posting, it might help other community members

  • Verified answer
    Marco Mels Profile Picture
    on at

    Thank you so much for sharing final outcome. This does help others in the community.

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,010

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans