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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s