Friday, 22 June 2018

Call PurchCreateOrder form event handler in dynamics 365

public class GHMCPurchOrderCreateFormEventHandler
{
    [PostHandlerFor(formStr(PurchCreateOrder), formMethodStr(PurchCreateOrder, run))]
    public static void PurchCreateOrder_Post_run(XppPrePostArgs args)
    {
        FormRun formRun = args.getThis();

        if (formRun.args().menuItemName() == menuItemDisplayStr(GHMCAffidavitPurchCreateOrder))
        {
            FormDataSource formDataSource = formRun.dataSource(tableStr(PurchTable));
            PurchTable purchTable = formDataSource.cursor();
            purchTable.PurchPoolId = GHMCPurchParameters::find().AffidavitPurchPoolId;
        }
    }

    [FormDataFieldEventHandler(formDataFieldStr(PurchCreateOrder, PurchTable, OrderAccount), FormDataFieldEventType::Modified)]
    public static void OrderAccount_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormDataSource formDataSource = sender.datasource();
        FormRun formRun = formDataSource.formRun();
         
        if (formRun.args().menuItemName() == menuItemDisplayStr(GHMCAffidavitPurchCreateOrder))
        {
            PurchTable purchTable = formDataSource.cursor();
            purchTable.PurchPoolId = GHMCPurchParameters::find().AffidavitPurchPoolId;
        }
    }
}

No comments:

Post a Comment

DefaultDimension in d365 FO X++

 Navigate to PurchTable methods you can find with DefaultDimension this.DefaultDimension = this.mergeDimension(this.getDefaultDimension(),th...