Wednesday, 12 December 2018

D365 Form button Control event handler

[FormControlEventHandler(formControlStr(HcmWorker, ArgsExampleButton), FormControlEventType::Clicked)]
    public static void ArgsExampleButton_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        Args args = new Args();
        Form formToCall = new Form('ArgsDemo_Callee');
        FormButtonControl callerButton = sender as FormButtonControl;  //Retrieves the button that we're reacting to
        FormRun form = callerButton.formRun(); //Gets the running HcmWorker form
        //Get the HcmWorker that was selected in the HcmWorker form
        FormDataSource hcmWorker_ds = form.dataSource(formDataSourceStr(HcmWorker, HcmWorker)) as FormDataSource;
        HcmWorker hcmWorker = hcmWorker_ds.cursor();
        //Set up args with all of the information you've retrieved                        
        args.caller(form);
        args.object(formToCall );
        args.record(hcmWorker);
        form = ClassFactory.formRunClass(args);
        form.init();
        form.run();
        form.wait();
    }

No comments:

Post a Comment