D365/AX7:Adding color to a form control of a standard or custom form by using event OnDisplayOptionInitialize

Here is the fixed for conditional coloring.

D365/AX7:OnDisplayOptionInitialize event is retrieving/getting always the first record

Requirement :

Adding color to “Product Name” string control of form “SalesTable” inside line grid.

Untitled

Sample Code & Instructions:

  1. Create a new class.
  2. Copy event handler method OnDisplayOptionInitialize of datasource “SalesLine” in form “SalesTable”.
  3. Paste the event handler method “OnDisplayOptionInitialize in class you created on step 1.[code language=”cpp”]/// ///
    ///
    ///

    ///
    ///
    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::DisplayOptionInitialize)]
    public static void SalesLine_OnDisplayOptionInitialize(FormDataSource sender, FormDataSourceEventArgs e)
    {
    FormDataSourceDisplayOptionInitializeEventArgs eventArgs = e as FormDataSourceDisplayOptionInitializeEventArgs;
    eventArgs.displayOption().affectedElementsByControl(sender.formRun().design(0).controlName(“ItemName”).id());
    eventArgs.displayOption().textColor(WinAPI::RGB2int(255,0,0));
    }[/code]

  4. Untitled

 

 

Cheers 🙂

Piyush Adhikari

 

One thought on “D365/AX7:Adding color to a form control of a standard or custom form by using event OnDisplayOptionInitialize”

Leave a Reply