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.
Sample Code & Instructions:
- Create a new class.
- Copy event handler method “OnDisplayOptionInitialize“ of datasource “SalesLine” in form “SalesTable”.
- 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]
Cheers 🙂
Piyush Adhikari
One thought on “D365/AX7:Adding color to a form control of a standard or custom form by using event OnDisplayOptionInitialize”