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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s