web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Business Central forum

How to move data to extensions in business central from my physical table fields in navision while upgrade

(0) ShareShare
ReportReport
Posted on by 12

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 #1512 (comment)

@umang11
  

umang11 commented 16 hours ago

So to achieve the above I had followed thee below steps but stucked at last point

  1. Created a table Customer UPG in development environment of Business Central
  2. Now created a upgrade code-unit and written code DataUpgradeMgt.SetTableSyncSetup(DATABASE::"Customer",DATABASE::"Customer UPG",TableSynchSetup.Mode::Copy);
  3. Now deleted the field from Customer table with run sync now.
  4. By doing the above field deleted from Customer and data moved to the Customer UPG Table.
  5. Now we had installed the extension which we had made for Customer table.
  6. 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.)
I have the same question (0)
  • THAKRJ Profile Picture
    35 on at

    Sure Steve, Not sure, how to do that. When I click on "Did this answer your question ?" it gives an error of no permission.

  • Community Member Profile Picture
    on at

    please verify the answer. if it helps you

  • THAKRJ Profile Picture
    35 on at

    Okay. Perfect :) That Clarifies !

    Thanks so much Steve. I appreciate your help !

  • Community Member Profile Picture
    on at

    question 1: no, it won't change anything

    Question2: yes, it depends on the number of records, it may take much time.

    if there is no change on the Keys or don't want to manipulate the data upon inserting to the extension the 2nd Method is better then the first one the timing

  • THAKRJ Profile Picture
    35 on at

    Okay Perfect ! Now 2 questions on 1st Method

    1) If we delete all Standard Records and move to Temp, will it create any validation changes or any data differences or after finishing the process, we will have the same data and no any difference ?

    2) IF we have lots of data for exmple. 20 Standard Tables with approx. 1200000 Records in each, will it take much time in this process execution ?

    Any suggestions ? Thank you so much Steve.

  • Community Member Profile Picture
    on at

    there are 2 different ways:

    copying all data to temp, deleting all records from the standard table, upgrading and then restoring from the temp to standard and extension

    another way:

    copying all data to temp, upgrading the tables, then restoring the customized code from temp to extension.

    the first code with insert in using for the first approach.

    for the second way, you need the filter the records on the table. insert the customized fields and modify

  • THAKRJ Profile Picture
    35 on at

    I am working on Upgarde from CAL to AL. Now, There are few Standard Tables having Custom Fields with data. So, I have to move those custom fields data to Extension fields from CAL. So, e.g There are 100 Customers in the Table. So, I just have moved only custom fields data to a temp Table with the Primary of Customer No. as well. So, that means, my Customer Table is not Empty bu having all 100 Customers inside. We just have to update the Custom fields data into that Table's extension.

  • Community Member Profile Picture
    on at

    it is true. but it shouldn't be the case because the table is empty at the beginning.

    if you want to modify, you should first use Setrange according to the Keys and find the filed then change the field data and modifying.

    it seems you didn't find the field, it created a new record with the customized fields and the rest with blank.

    same as the last code

  • THAKRJ Profile Picture
    35 on at

    Yes, That's correct ! I have 2 Extensions ! Custom Fields Extejnsion and also a Upgrade Extension. But, it seems, like when Upgrade extension checks, if Customer Record already exists, it does not update other fields too using INSERT.

  • Community Member Profile Picture
    on at

    upon inserting the data into the standard table it inserts data into the extension table as well. I mean it sees one table (which is the combination of the standard and the extension table)

    did you put your extension and dependency of upgrade data extension?

    you suggest having 2 extensions, application extension and data upgrade extension. the data upgrade extension must have th edependency of application extension on app.json

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans