Changing Form color based on the current Company in Ax 2012

Changing Form color based on the current Company

By default, all the forms look the same. This can be confusing for those super users that switch between companies preforming different task.

Well I came across a neat little trick that I am going to post here. I am not sure how well this will work in Dynamics AX 4.0, but for AX 3.0 it works great.

Basically you override the SysSetupFormRun.run() method. Below is some sample code:

public void run()
{
;
super();

// Set the color scheme of this instance of te SysFormRUn to RGB
this.design().colorScheme(FormColorScheme::RGB);

// Switch and based on the current company change colors, or not for default
switch (curext())
{

case ‘DEM’:
this.design().backgroundColor(WinAPI::navisionColorRed());
break;

case ‘dat’:
this.design().backgroundColor(WinAPI::navisionColorBeige());
break;

default:
break;

}
}

Now when you switch between the two companies and launch a form, you will see visually, that you are in a different company. Granted the WinAPI::navisionColorBeige(), ..Blue(), ..Red() are not that great looking, but still you get the idea. And if you know RGB colors, then you can supply really any valid RGB color you like!

Anyway this is a neat little trick that is ran each time a new instance of a given form (other that the main menu) is ran.

Advertisements

Color-code your Dynamics environments in Ax 2012

Color-code your Dynamics environments

Since implementing Axapta / Dynamics AX in 2003, we’ve found it invaluable to provide an environment for testing and training as well as our live system (or production environment) to end users. This lets people try different processes or train new employees without fear of screwing up the “real” data.

Occasionally, though, we’ve run into a problem where someone thought they were using the live system, but were actually in the test environment. It’s an easy mistake to make. There is no obvious visual cue to alert a user that they are working on a test system.

There is a way change the color of the Dynamics forms to help indicate what environment is in use. It involved overriding the SysSetupFormRun.run() method, which will be called every time a form is opened. On the class SysSetupFormRun, create a new method with this code:

public void run()
{
SysSQLSystemInfo systemInfo = SysSQLSystemInfo::construct();
;
super();

// Set the color scheme of this instance of the SysFormRun to RGB
this.design().colorScheme(FormColorScheme::RGB);

// If the database name is not the live version, change the color of the form

if (systemInfo.getloginDatabase() != ‘MyDBName’)
this.design().backgroundColor(0x112255);
}

That’s all there is to it. If your live and test systems use the same database name, but the AOS is running on different servers you can modify this code to to match on systemInfo.getLoginServer() != ‘MyServerName’. You can change the color by setting the hex value. It uses the RGB values in reverse order: 0xBBGGRR.

Variations of this code could switch form colors to indicate the current user account, application layer, or company. Less practical uses could match color to the time of day or season of the year. If you find this code useful, leave me a message noting what you did with it.

=========================

For more information on changing form colors and sample code for version 3.0, see:

http://dynamics-ax.blogspot.com/2006/04/changing-form-color-based-on-current.html

=======================

Sample screens showing how the code above changes the test environment forms compared to the same form in the live production environment.

 

Ref : http://discoverax.blogspot.in/2007/12/color-code-your-dynamics-environments.html