Skip to main content

Notifications

Announcements

No record found.

How to call part form method by parent from event handler? #D365 #ax #dynamics

Here we have a form part on the SalesTable form to show the total weight. 

blog.png

If we want to call any part form method from the parent form by any event that occurred, We can use this code.

Here we are calling the functionality of the refresh.

    [FormControlEventHandler(formControlStr(SalesTable, SalesLine_SalesQty), FormControlEventType::Modified)]

    public static void SalesLine_SalesQty_OnModified(FormControl sender, FormControlEventArgs e)

    {

        PartList partList = new PartList(sender.formRun());

        str formName = 'salesTotals';

        SalesTable salesTable = sender.formRun().dataSource(1).cursor();

        FormPartReferenceControl formPartControl = PartList::getSalesTablePartControlByFormName(partList, formName);

        FormRun formRun = formPartControl.getPartFormRun();

        FormCommandButtonControl refresh = formRun.design().controlName(formControlStr(cmaSalesTotals, RefreshLink));

        FormRealControl totalWeight = sender.formRun().design().controlName(formControlStr(SalesTable, NCR_TotalWeight));

        refresh.clicked();

        totalWeight.realValue(salesTable.getTotalWt());

    }

Comments

*This post is locked for comments