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 :
Microsoft Dynamics AX (Archived)

X++ Class methods called after the company is changed

(0) ShareShare
ReportReport
Posted on by 259

Hi Everyone,

I have some code that is needed to be called after a user changes the company. Can any one please help me identify if there are any methods which get called after company has been changed in AX.

Thanks,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    PA-22040759-0 Profile Picture
    6,194 on at

    The following method changes the Company for the user, when they are using the change company dialog:

    \Forms\SysDataAreaSelect\Methods\SwitchCompany

  • Verified answer
    Community Member Profile Picture
    on at

    If you want to cover every area in the system where you can change companies, you will need to start looking into the Application class.  Take a look at the setDefaultCompany method.  There is a warning output there that warns the user that they have changed companies (as long as they have this warning turned on in user options).  Depending on your requirements, you can use this same type of functionality to handle a change of companies.  

    Hope this helps, good luck!

    Best Regards.

  • Verified answer
    Community Member Profile Picture
    on at

    I suggest you should consider overrriding following

    Classes\Application\setDefaultCompnay()

    just before return statement

    If you review this method you will find that system is setting all the required variables before return statement

    so you should put your code after all the required variables are set.

    Please verify and udpate us with your findings.

  • Nayyar Siddiqi Profile Picture
    259 on at

    Thanks for the replies guys, I would try these out and would let you know,

    Eid Mubarak ! :)

  • Community Member Profile Picture
    on at

    HI Nitesh & Nayyar,

    I have the same type of requirement.

    I am able to hide the modules if I write the code in SwitchCompany() of SysDataAreaSelect. But if I call my class which is hiding the module in the Application class (setDefaultCompany) method, AX is chrashing once I change company from the address bar.

    Please note, I have called my class just before the "return" statement of the setDefaultCompany method. Please help.

    Thanks in advance!

    -Mriganka

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans