Monday, November 15, 2021

How to refresh caller datasource in D365fo

 Today we discuss how to refresh the caller form from another form using x++. I have to refresh the caller form after inserting data in the caller table. For this, we have multiple ways. follow any one of the below-mentioned ways.


1. I have used FormDataUtil calss.

    Mytable = element.args().record(); FormDataSource formdataSource = FormDataUtil::getFormDataSource(Mytable); formdataSource.research(true); // FormDataUtil::getFormDataSource(Mytable).research(true);we can use directly like this


2. Get the form data source from args. (This is a simple one)

    FormDataSource formdataSource = element.args().record().dataSource(); //formdataSource.research(); formdataSource.refresh(); formdataSource.executeQuery(); //element.args().record().dataSource().research(true); we can use directly like this

3. Get the caller and refresh the data source. We can use only form is calling another form menu item button instead of Args class.

    FormRun formRun; ; formRun = element.args().caller(); formRun.dataSource().refresh(); formRun.dataSource().research(true);


4. We can use the task method in formrun. We can use only form is calling another form menu item button instead of Args class.                

    #Task FormRun formRun; // Get an instance of the calling form. formRun = element.args().caller(); // If the caller is a form, refresh that form. if (formRun) { formRun.task(#taskF5); }

Reference: https://docs.microsoft.com/en-us/dynamicsax-2012/developer/how-to-refresh-the-calling-form

Keep Daxing!!

No comments:

Post a Comment