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
}

Unknown's avatar

About janeteblake

My triple passions are Dynamics AX technical, learning, and AI
This entry was posted in AX2012, Dynamics AX. Bookmark the permalink.

Leave a comment