Wednesday, 21 August 2019

Form post_init in D365

[PostHandlerFor(formStr(PSAUpdatePercent), formMethodStr(PSAUpdatePercent, init))]
    public static void PSAUpdatePercent_Post_init(XppPrePostArgs args)
    {
        real                            percent;
        FormRun                         formRun =   args.getThis();
        FormRealControl                 realControl, currentPercent;
        real                            currentValue;
        PSAContractLineItems            pasContractLineItems=   formRun.args().record();
        INTC_UnitDetails_EventHandler   eventHanlderClass   =    new INTC_UnitDetails_EventHandler();

        percent         =   eventHanlderClass.getPercent(pasContractLineItems.RecId);
        realControl     =   formRun.design().controlName('RevisedPercent');
        currentPercent  =   formRun.design().controlName('currentPercent');
        currentValue    =   currentPercent.realValue();

        realControl.realValue(percent-currentValue);
    }

Form data source OnInitialized D365

[FormDataSourceEventHandler(formDataSourceStr(ProjProjectsListPage, ProjTable), FormDataSourceEventType::Initialized)]
    public static void ProjTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
    {
        ProjTable                   projTable     = sender.cursor();
        FormDataSource              projTable_ds  = sender.formRun().dataSource('ProjTable');
        FormRun                     element       = sender.formRun();
        FormControl                 groupChangeButton;
   
        groupChangeButton = element.design().controlName("ProjGroupChange");
        groupChangeButton.visible(false);
    }