AX / D365FO – Simple Class to perform database sync for a single table

This simple runbase class is a ready-to-use tool to perform a Database synchronization for a single table

Through X++ code we can perform database synchronization either on a required table (or) on all tables bases on our requirement.

This could be very useful during on-premises environments package deployments because can can drastically reduce the downtime.

In fact you can only synchronize the tables that you have actually modified rather than perform an entire synchronization

class OTS_DBSynchronize extends RunBaseBatch
{
    DialogField tableDlg;
    TableName   tableFld;

    public container pack()
    {
        return conNull();
    }

    public boolean unpack(container packedClass)
    {
        return true;
    }

    public Object dialog()
    {
        Dialog dialog = super();

        dialog.caption("@OTS:OTS_624_625_EURO_TON_Valorisation_03");
        tableDlg = dialog.addField(extendedTypeStr(TableName), 'Table');
        return dialog;
    }

    public boolean getFromDialog()
    {
        tableFld = tableDlg.value();
        return super();
    }

    public void run()
    {
        appl.dbSynchronize(tableName2id(tableFld), false);
    }

    public static void main(Args _args)
    {
        OTS_DBSynchronize self = new OTS_DBSynchronize();

        if (self.prompt())
        {
            self.run();
        }
    }

}

The class opens a dialog.

Insert your table and press OK

5 responses to “AX / D365FO – Simple Class to perform database sync for a single table”

  1. Nikhil Avatar
    Nikhil

    How to clear the ssrs report parameter in d365 F&O

    Like

  2. Nikhil Avatar
    Nikhil

    I have a lookup field in report dialog. And I need to clear that lookup parameters After I clicking the ok button

    Like

  3. Bilal Avatar
    Bilal

    How we can perform database sync for all tables?

    Like

  4. Bilal Avatar
    Bilal

    For all tables, we have to give 1st parameter zero.

    appl.dbSynchronize(0, false);

    Like

    1. Marco Saad Avatar
      Marco Saad

      Great!! I didn’t knew.
      Thanks

      Like

Leave a comment