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, ...
Suggested Answer

Change background color or text style of DimensionEntry control in X++

(1) ShareShare
ReportReport
Posted on by 192
Hello Experts,
I need to change Financial dimension background color or text style or if we can put additional caption around CostCenter saying [mandatory] on vendTable form in D365FO in version 10.0.31 (10.0.1406.58).
Can please guide how I can achieve this using x++ code .
 
I have the same question (0)
  • Suggested answer
    Hana Xue Profile Picture
    Microsoft Employee on at
    Hi,
    There is a similar issue mentioned in the old thread of the forum, you can check it out:
    Dynamics Community Forum Thread Details
    Best Regards,
    Hana
  • Mitr Profile Picture
    192 on at
    Hello Hana,
    Thank you very much for your response however the link you have given seems to be of D365CE however I looking for a solution in D365FO in version 10.0.31 (10.0.1406.58).
    Please let me know if you have a solution for D365FO.
     
    Thanks
    Mitr
  • Hana Xue Profile Picture
    Microsoft Employee on at
  • Suggested answer
    Umesh Pandit Profile Picture
    9,315 User Group Leader on at
    Hey Mitr,
     
    In Microsoft Dynamics 365 Finance and Operations, the DimensionEntry control is used to display and edit dimensions. You can change its background color or text style using X++ code. Here's an example of how you can achieve this:
     
     
    DimensionEntry dimensionEntry;
    int bgColor;
    int textColor;
    // Get a reference to the DimensionEntry control
    dimensionEntry = YourFormName.controlName; // Replace with the actual form and control name
    // Set background color (for example, yellow)
    bgColor = WinAPI::RGB2int(255, 255, 0); // Yellow color
    dimensionEntry.backgroundColor(bgColor);// Set text color (for example, red)
    textColor = WinAPI::RGB2int(255, 0, 0); // Red color
    dimensionEntry.color(textColor);
     

    In this code, replace YourFormName with the actual name of your form and controlName with the name of your DimensionEntry control.

    Please note that modifying the appearance of controls using X++ code might require knowledge of the specific form's structure and event handling. Make sure to adjust the code according to your needs and integrate it into the appropriate event handler within your form.

    Remember to thoroughly test the changes in a development or test environment before applying them to a production environment.
     
     
  • Mitr Profile Picture
    192 on at
    Hello Umesh,
    Thank you very much for your response.

    I used your suggestion and wrote below code in OnInitialized Event of form VendTable.

     
    [ExtensionOf(formStr(VendTable))]
    final class HEX_VendTable_HEX_Extension
    {
        
        
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        [FormEventHandler(formStr(VendTable), FormEventType::Initialized)]
        public static void VendTable_OnInitialized(xFormRun sender, FormEventArgs e)
        {
            FormRun formRun = sender;
            DimensionEntryControl dimensionEntryControl;
            int bgColor;
            int textColor;
            
            // Get a reference to the DimensionEntry control
            dimensionEntryControl = formRun.design().controlName('DimensionEntryControl') as DimensionEntryControl;
            
            if (dimensionEntryControl)
            {
                // Set background color (for example, yellow)
                bgColor = WinAPI::RGB2int(255, 255, 0); // Yellow color
                dimensionEntryControl.backgroundColor(bgColor);
                
                // Set text color (for example, red)
                textColor = WinAPI::RGB2int(255, 0, 0); // Red color
                dimensionEntryControl.color(textColor);
            }
            
            // Continue the original init() method
            next VendTable_OnInitialized(sender, e);
        }
        
    }
     
    However getting error:
     
    Error        ClassDoesNotContainMethod: Class 'DimensionEntryControl' does not contain a definition for method 'color' and no extension method 'color' accepting a first argument of type 'DimensionEntryControl' is found on any extension class.
     
    Error        ClassDoesNotContainMethod: Class 'DimensionEntryControl' does not contain a definition for method 'backgroundColor' and no extension method 'backgroundColor' accepting a first argument of type 'DimensionEntryControl' is found on any extension class.

    Can please help on this.
    Thanks

    Mitr
  • Mitr Profile Picture
    192 on at
    Hello Hana,
    Thank you for your response however it did not work.
     
    I will try to find any other way to get it done, If I get it done perfect I will let you know here .
     
    Thanks
     
    Mitr

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 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans