On possible way would be to copy/move your Data into DataUpgrade-Tables.
Customer Field
Create a new Table 90000 Customer UPG with two fields, the Primary Key of Table Customer ( "No.") and Field 50000 Foo.
Your Upgrade Codeunit 90000 should have following entry to copy that data:
DataUpgradeMgt.SetTableSyncSetup(DATABASE::"Customer",DATABASE::"Customer UPG",TableSynchSetup.Mode::Copy);
If you import the new Customer Table, where Field Foo was deleted, the Customer UPG Table and the Upgrade Codeunit, the Table Synchronisation (Schema: Now) would copy every entry of the Customer Table with the value of Foo into the Upgrade Table Customer UPG before deleting the Field Foo from the Customer Table.
With a second Upgrade Codeunit 90001 and Upgrade Function (Subtype UpgradePerCompany) inside you AL extensions, you can move the Data back.
if CustomerUPG.FINDSET then begin
repeat
Customer.GET(CustomerUPG."No.");
Customer.Foo := CustomerUPG.Foo;
Customer.MODIFY;
until CustomerUPG.NEXT = 0;
CustomerUPG.DELETEALL;
end;
Custom Table
Create new Table 90001 Foo UPG with the same Fields of Foo.
Your Upgrade-Codeunit 90000 should have following entry:
DataUpgradeMgt.SetTableSyncSetup(DATABASE::"Foo",DATABASE::"Foo UPG",TableSynchSetup.Mode::Move);
After you import the new Foo UPG Table and the Upgrade Codeunit, the Table Synchronisation (Schema Now) for deleting Table Foo should move all that Data into Foo UPG.
Also in the second Upgrade Codeunit 90001 and additional Upgrade Function inside you AL extensions, you can move the Data back into the new Table Foo.
if FooUPG.FINDSET then begin
repeat
Foo.TRANSFERFIELDS(FooUPG);
Foo.INSERT;
until FooUPG.NEXT = 0;
FooUPG.DELETEALL;
end;
@DanielGoehler we followed the above step but we are stuck at a point where we had moved the data of customized filed of table in UPG Table which is created in NAV development environment, but we are unable to find that table in the visual studio code while trying to move data from UPG table to my extended table.
Originally posted by @DanielGoehler in https://github.com/Microsoft/AL/issues/1512#issuecomment-361361137
So to achieve the above I had followed thee below steps but stucked at last point
- Created a table Customer UPG in development environment of Business Central
- Now created a upgrade code-unit and written code DataUpgradeMgt.SetTableSyncSetup(DATABASE::"Customer",DATABASE::"Customer UPG",TableSynchSetup.Mode::Copy);
- Now deleted the field from Customer table with run sync now.
- By doing the above field deleted from Customer and data moved to the Customer UPG Table.
- Now we had installed the extension which we had made for Customer table.
- Now we are stuck at this point(As we are unable to write code by using Customer UPG table in visual studio code and also we are unable to find the field of extended table of customer in NAV Development environment so where we can write code to move data from Customer UPG to extended field of customer table in extension.)
This repository no longer handles general questions and is only dedicated to bug reports and feature suggestions for the AL compiler and developer tools
To get help please use one of the following resources: Business Central Community mibuso forum Dynamics User Group