Showing posts with label Refresh caller form. Show all posts
Showing posts with label Refresh caller form. Show all posts

Thursday, January 12, 2023

Auto refresh the parent form when child form is closed using x++

 I got a requirement to refresh the parent form If the child form is closed or any dialog form is open from the parent form.

  • For this, I have used the "FormHasMethod" standard function.
  • I have created a new method in my parent form. Check the Below code.

[ExtensionOf(formStr(SalesLineOpenOrder))]
final class SalesLineOpenOrder_Extension
{
    public void RefreshSalesLine()
    {
        SalesLine_DS.research();
    }
}


On closing of child form write the following method :

    public void close()
    {
	super();

	if(formHasMethod(element.args().caller(), identifierstr(RefreshSalesLine)))
	{
		FormRun formRunObject = element.args().caller();

		formRunObject.RefreshSalesLine();
	}
    }


Keep Daxing!!

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!!

Monday, April 5, 2021

REFRESH CALLER FORM DATASOURCE FROM A CLASS IN D365FO/AX7

 REFRESH CALLER FORM DATASOURCE FROM A CLASS IN D365FO/AX7.


Please check the below code.

 private static void main(Args _args)

{

        Test                            testTable;

        TestClass                       testClass;

        FormDataSource                  formDs;

        int                             position;

        ;

        if (_args && _args.dataset() == tableNum(Test))

        {

            testTable = _args.record();

        }

        testClass = new TestClass();

        formDs = FormDataUtil::getFormDataSource(testTable);

        //formDs =  _args.record().dataSource();

        testClass.checkStage(testTable, testmethod);

        

        if (testTable.RecId && formDs)

        {

            position = formDs.getPosition();

            formDs.research();

            formDs.setPosition(position);

        }

}

Keep Daxing!!

Wednesday, October 21, 2020

Refresh DataSource and retain to same position in Ax 2012 X++

 

Hi guys, Today we see when I run execute query I don't want to change active record cursor position in ax 2012 X++.Refresh DataSource and retain to same position.

Here we have 2 ways Just check below.

Code 1:  Here we use Get and Set methods.

    Int         position;

    position = TestTable_ds.getPosition();

   TestTable_ds.executeQuery();

    TestTable_ds.setPosition(position);


Code 2:  we can use Recid also. This is more efficient compared Code 1.

    TestTable    testTable;

    testTable.RecId = TestTable.RecId;

    TestTable_ds.executeQuery();

    TestTable_ds.findRecord(testTable); 


Keep Daxing!!