Monday, June 02, 2008

How to change Background color of the forms depending on the company you are in (Differentiate The Companies U login in AX)

add a field- color (integer type) , in the table CompanyInfo
give some values (ex -255)
and add the following codes in the class
SysSetupFormRun

public void run()
{
FormDesign formDesign = this.design();
container con;
;
#WinAPI
super ();

if (FormDesign)
{
FormDesign.colorScheme(2);

if(CompanyInfo::find().Color != 0)
{
FormDesign.backgroundColor(CompanyInfo::find().Color);
}
else
{
con = winapi::getSysColor(#COLOR_BTNFACE);
FormDesign.backgroundColor(winapi::RGB2int(conpeek(con,1),
conpeek(con,2), conpeek(con,3)));
}
FormDesign.caption(CompanyInfo::find().Name);
}

}
1. login in to the company accounts open AOT and open table browser for CompmanyInfo Table and give some values for the field "color" eg(255)
2. then log in to another company and repeat the above step

Check the difference

No comments: