web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Changing the background colour of controls on a form

(0) ShareShare
ReportReport
Posted on by 213

Hi

I have a requirement to change the color of a few controls on a form, and understand this is only possible through code is that correct?

If so, should I be extending the form, the form datasource or the individual controls themselves?

And would this be easier to achieve via event handlers or CoC?

Many thanks in advance

I have the same question (0)
  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    You can use control's  BackgroundColor property (control.BackgroundColor())

    If you're going to make changes to more than one control, it's easiest to write the form's extension via COC. (don't forgot set auto declaration to Yes)

  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi,

    You can set the property by code just set the following 2 properties:

    Element.colorScheme(FormColorScheme::RGB);
    
    Element.backgroundColor(WinAPI::RGB2int(255,205,65));

    https://chaituax.wordpress.com/2013/03/07/setting-background-color-to-a-field-in-a-form/

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/user-interface/specify-color-font-background-controls

    regards

  • cjohnson300 Profile Picture
    213 on at

    Posting my code to help others in the future

    [ExtensionOf(formStr(VendTable))]
    final class ABC_VendTable_Extension
    {
        public void setFieldColours()
        {
            OrgDetailGroup_NumberOfEmployees.colorScheme(FormColorScheme::RGB);
            OrgDetailGroup_NumberOfEmployees.backgroundColor(WinAPI::RGB2int(255,173,119));
    
            OrgDetailGroup_OrgNumber.colorScheme(FormColorScheme::RGB);
            OrgDetailGroup_OrgNumber.backgroundColor(WinAPI::RGB2int(165,241,169));
        }
    
        [FormDataSourceEventHandler(formDataSourceStr(VendTable, VendTable), FormDataSourceEventType::Activated)]
        public static void  VendTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        {
            FormRun formRun = sender.formRun();
    
            if (formHasMethod(formRun, "setFieldColours"))
            {
                formRun.setFieldColours();
            }
        }
    
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans