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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans