Form colors in Dynamics AX 2012

A client wanted form color to reflect the environment (AOS) they were in. It’s changed a bit in 2012. I found a post online but had to tweak it to work for me. Here is the code.

Sorry for the layout; still getting the hang of this blogging thing.

Class SysSetupFormRun method init

public void init()
{
SysSQLSystemInfo systemInfo = SysSQLSystemInfo::construct(); // mca jeb 05Nov2012
str databaseName; // mca jeb 05Nov2012

super();

if (this.isWorkflowEnabled())
{
workflowControls = SysWorkflowFormControls::construct(this);
workflowControls.initControls();
}

// mca jeb 05Nov2012 begin
this.design().colorScheme(FormColorScheme::RGB);
databaseName = systemInfo.getloginDatabase();
switch (databaseName)
{
case “DAX2012_DEV”:
this.design().backgroundColor(WinAPI::RGB2int(224, 176, 255));//mauve
break;
case “DAX2012_CRP”:
this.design().backgroundColor(WinAPI::RGB2int(255,255,153));//canary
break;
case “DAX2012_TEST”:
this.design().backgroundColor(WinAPI::RGB2int(152,251,152));//pale green
break;
case “DAX2012_PREPROD”:
this.design().backgroundColor(WinAPI::RGB2int(255,99,71));//tomato
break;
default:
info(strFmt(“Database %1 does not have a color”, databaseName));
}
// mca jeb 05Nov2012 end
}

Advertisements

About janeteblake

Dynamics AX developer
This entry was posted in AX2012, Dynamics AX. Bookmark the permalink.

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