D365FO auto refresh page

We needed auto refresh functionality in maintenance department for monitoring purposes . We created a new form and showed it on TV screen.

Settimeout method on Ax2012 has retired/deprecated and replaced with SetTimeOutEx function. You can use same logic to refresh your pages.

https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/migration-upgrade/deprecated-apis

Here is a sample code on Fleetmanagement customer page:

[Form]
public class FMCustomer extends FormRun
{
    public void init()
    {
        QueryFilter qFilter;
        QueryBuildDataSource qbd;

        super();

        qbd = FMCustomer_DS.queryBuildDataSource();

        qFilter = FmCustomer_DS.query().addQueryFilter(qbd, fieldstr(FMCustomer, FirstName));
        qFilter = FmCustomer_DS.query().addQueryFilter(qbd, fieldstr(FMCustomer, LastName));
        qFilter = FmCustomer_DS.query().addQueryFilter(qbd, fieldstr(FMCustomer, CellPhone));
        qFilter = FmCustomer_DS.query().addQueryFilter(qbd, fieldstr(FMCustomer, Email));
    }

    /// <summary>
    ///
    /// </summary>
    public void run()
    {
        super();
        element.setTimeOutex(identifierstr(refreshForm), conNull(),5000);
    }

    public void refreshForm(AsyncTaskResult _result)
    {
        if (!element.closed()) //otherwise will be executed even after form close.
        {
            element.setTimeOutex(identifierstr(refreshForm), conNull(),5000);
            FMCustomer_DS.research(true);
        }
    }

}

Leave a Reply

Your email address will not be published. Required fields are marked *