Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Jesús Almaraz blog / New feature in Renumbering ...

New feature in Renumbering extension: empty table objects

Fast context
In my extension https://marketplace.visualstudio.com/items?itemName=JessAlmarazMartin.JAMRenumbering  some time ago I did a new feature to create new tables without logic based on al the tables and table extensions. The purpose of this feature was to ease upgrading processes, getting a copy of the tables to save de data.
The command "JAM Generate empty logic table objects in target folder", generate a copy without logic of all the workspace tables and table extension in the target folder that you choose in the process:
​​​​​​​
Improvements
With the daily work I detected some issues, and I fixed them. In addition, I add this features to the command:
  • Before choose the folder, you set in a quick pick the first number of new empty objects:
  • As did in the previous version, choose the target folder to the empty tables.
  • Create automatically a codeunit to transfer the data form original tables to new empty tables, and back from empty to original tables, to ease upgrade and transformation processes.
The result is in the target folder, with the empty logic tables and the install codeunit.
Breakdown of the install codeunit
The resulting install Codeunit have the following automatic sections. First of all, the declaration:
codeunit 99010 "Save Data To TempTables"
{
    Subtype = Install;
Then here we have the installation trigger with two procedure calls commented:
    trigger OnInstallAppPerCompany()
    begin
        //SaveTables();
        //BackToTables();
    end;

Depending on the use of the app you must uncomment any of this two functions.
First function “SaveTables” move data form original to empty tables:
    local procedure SaveTables()
    begin
        SaveTIPItemLedgerEntry();
        SaveTIPAssistantSetup();
        SaveTIP001TestTableTIP001();
        SaveSalesPromotion();
        SaveMovposicióndetallado();
        SaveEXTCustInvoiceDisc();
Each function uses a DataTransfer type to move data:
    local procedure SaveTIPAssistantSetup()
    var
        DataTransfer: DataTransfer;
        FromTable: Record "TIP Assistant Setup";
        ToTable: Record "99011 TIP Assistant Setup";
    begin
        DataTransfer.SetTables(FromTable.RecordId.TableNo, ToTable.RecordId.TableNo);
        DataTransfer.AddFieldValue(FromTable.fieldno("Primary Key"), ToTable.fieldno("Primary Key"));
        DataTransfer.AddFieldValue(FromTable.fieldno("LUIS subscription key"), ToTable.fieldno("LUIS subscription key"));
        DataTransfer.AddFieldValue(FromTable.fieldno("Picking Mode"), ToTable.fieldno("Picking Mode"));
………………….
        DataTransfer.AddFieldValue(FromTable.fieldno("Report ID"), ToTable.fieldno("Report ID"));
        DataTransfer.CopyRows();
    end;

The datatranfer is an ultra-optimized way to transfer data from a table to another:
Transferring data between tables using DataTransfer - Business Central | Microsoft Learn
The “BackToTables” procedure do the same but in opposite direction, from new empty tables to original.
The codeunit is called “Save Data To TempTables” and all the procedures are automatically created in the empty tables’ creation. But I detected al least two issues.

(Not important) Issues
I detected two issues:
  • The tables from table extensions are not correct, and you must complete them manually, because they do not have primary key and the fields that compose this key. You must fix the procedures of these tables manually also.
  • The flow fields are correctly excluded from the empty tables, but not form the procedures so this fields will raise compilation error and you must remove the lines.
I am proud of my extension maintenance, but these two issues are not in my immediate agenda, so could be there for some weeks before I fix them. I think is easy to fix that manually for a time.

Comments