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

Popular posts from this blog

Build HTML and send email in D365 FO with X++

How to customize electronic reporting in D365

Batch parallelism or multithreading in Dynamics 365 for Finance and Operations

How to Enable/Disable a Form Button with X++

How to create and run the Runbase batch class in D365

Difference between InMemory and TempDB tables in D365 F&O

How to create and run the Runbase class in D365

Customize the standard excel template in D365FO

How to apply a package in LCS Dynamics 365 F&O

How to create and run a batch class that extends RunBaseBatch in D365