Tuesday 13 May 2008

Identifying Production, UAT and DEV Environments on the Status Bar

In AX 4, the lack of ability to easily identify whether the AX window you have open is the production, UAT or development system is something that I find really painful at times. Perhaps its my bad habit of having multiple instances of each open at any given time that causes the problem, but I often find myself closing every open instance and reopening because I've forgotten which is which.


My current solution interferes slightly with version control, so if you're using a version control system with AX you'll have to test this for yourself (the init method of the VersionControl class writes to the custom item area on the status bar as well).


This simple mod works by modifying the startupPost method of the Application class so that at startup, the database server name as well as the database name are written to the status bar using the Infolog.WriteCustomStatlineItem method.


The modified Application class code below first enables the custom stat line text functionality for the current user and then writes the relevent SysSQLSystemInfo to the status bar.


void startupPost()
{
SysSQLSystemInfo systemInfo = SysSQLSystemInfo::construct();
;

xUserInfo::statusLine_CustomText(true);
infolog.writeCustomStatlineItem (systemInfo.getLoginServer() + ' :: ' + systemInfo.getloginDatabase());
}


The problem is this still doesn't work as VersionControl.Init, which is called during startup, after Application.StartupPost, sets the custom stat line item to an empty string method.


The solution to this is to simply comment out infolog.writeCustomStatlineItem(''); in the VersionControl class.

This is the final result (where the DB server is AXAPTA1 and the DB name for the UAT is Dynamics-UAT):




As you can see above, with our DB naming structure, this provides a very obvious and simple way of identifying which environment the current window relates to.