Changing Form color based on the current Company
I don't know about you, but I have in the past wanted a way to visually show that a user was in a given 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.
Well check back soon for more helpful hints!
Find a job at: www.DynamicsAXJobs.com
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.
Well check back soon for more helpful hints!
Find a job at: www.DynamicsAXJobs.com
5 Comments:
This comment has been removed by a blog administrator.
Hi all,
It's great !
There is another sample like this in www.trucosax.com in downloads/tunning Axapta. This one lets the user choose what color he wants for every company. (must be registered user to download it :( )
Best regards,
Mkz.
---------
www.trucosax.com
A Dynamics Ax (Axapta) tricks site in Spanish language :)
This comment has been removed by a blog administrator.
I wonder why does the code for setting the color scheme must come after the super() call in Run() method to work.
Also, if one changed those 2 properties @ AOT object before running the form, the result seems different.
Is there any reference/information about such behavior that I can read?
Cheers
Hey,
I used a version of your code to change the color of the forms in our testing / training environment. This will help keep our company's employees from accidentally working in the wrong environment.
See it here:
http://discoverax.blogspot.com/2007/12/color-code-your-dynamics-environments.html
Thanks for all the suggestions!
Reiff Lorenz
http://discoverax.blogspot.com/
Post a Comment
<< Home