AX/D365-How to display the custom line entity on the form
To display a custom line entity on a form that includes the header entity and line entity, use the attached code:
[FormEventHandler(formStr(YourFormName), FormEventType::Initializing)]
public static void YourFormName_OnInitializing(xFormRun sender, FormEventArgs e)
{
FormRun formRun = sender as FormRun;
if (formRun)
{
OfficeFormRunHelper officeHelper = formRun.officeHelper();
if (officeHelper)
{
officeHelper.OfficeMenuInitializing += eventhandler(YourClass_EventHandler::officeMenuInitializingHandler);
}
}
}
private static void officeMenuInitializingHandler(FormRun _formRun, OfficeMenuEventArgs _eventArgs)
{
OfficeMenuOptions menuOptions = _eventArgs.menuOptions();
OfficeMenuDataEntityOptions entityOptions = menuOptions.getOptionsForEntity(tableStr(YourEntity));
if (!entityOptions)
{
// The entity options were not included. Add them.
entityOptions = OfficeMenuDataEntityOptions::construct(tableStr(YourEntity));
menuOptions.dataEntityOptions().addEnd(entityOptions);
}
}
Comments
Post a Comment