The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
We have seen how to create Upgrade code unit in our previous post.
Please go through it, if not seen earlier the Data Upgrade Codeunit in Navision 2015 – Part -1 here
Let us continue from where we left our previous post.
We have created the Upgrade code unit to copy the data to upgrade table while performing destructive changes to My Sales Customer table.
We removed certain fields from the My Sales Customer table and the related information was moved to UPG My Sales Customer table.
Now it’s time to move these information to actual table we create for this purpose My Detailed Customer Entry table.
Although in this example this table will be exact copy of UPG My Sales Customer table, so simply we need to copy records to My Detailed Customer Entry table.
But some time we may require to add certain more field’s value while moving the data Like Entry No, Posting date to maintain the data integrity. Like think of some Service type of information you are maintaining then the same set of record may repeat number of times on different dates, then in this case we will require to add certain fields like Entry No. and Posting Dates.
Let us assume we will be maintain data of My Detailed Customer Entry in incremental way as of situation on every transaction. Balances will be maintained as of when transaction was performed.
Although this example is not feasible or practice but still we are continuing to just see how to write Upgrade Function for such purpose.
Our today’s task is to design and run data upgrade function to move data from the upgrade table to its new location.
Now the fields are deleted from the My Sales Customer table and the data is saved in the UPG My Sales table. The next step is to create the new table where the data will reside (My Detailed Customer Entry) and move the data into that table.
Let’s create the table to be used for recording of all future Customer Balances and to accommodate the data we already had in the My Sales Customer table and which we moved into the UPG My Customer table.
We will now create a new function which will contain the code to migrate the data from the upgrade table to the new table.
Note that the FunctionType property of the newly created function is set to “Upgrade”. This is how the NAV server can later figure out which function from the upgrade codeunit it must execute.
The function marked as “Upgrade” function can call functions marked as “Normal” if necessary.
The code we add to the UpgradeCustomerDetails function will copy the data from the UPG My Sales Customer table to the My Detailed Customer Entry table and then clean up the UPG Vehicle table.
//>> Upgrade Code
EntryNo := 1;
WITH UpgCustomer DO BEGIN
IF FINDSET THEN
DetailedCustomerEntry.”Entry No.” := EntryNo;
DetailedCustomerEntry.”Customer No.” := “Customer No.”;
DetailedCustomerEntry.”As of Date” := today;
DetailedCustomerEntry.”Last SO Value” := “Last SO Value”;
DetailedCustomerEntry.”Last Invoiced Value” := “Last Invoiced Value”;
DetailedCustomerEntry.”Total Outstanding Value” := “Total Outstanding Value”;
EntryNo := EntryNo + 1;
UNTIL NEXT = 0;
You can start the data upgrade process from the Dev. Environment, or from Microsoft Dynamics NAV 2015 Administration Shell, using Start-NAVDataUpgrade cmdlet.
The NAV server will locate all upgrade codeunits and will invoke all upgrade functions within these codeunits for all companies in the database.
If you have multiple upgrade functions in your upgrade codeunit, you can choose to execute them in parallel or in sequence. You can also choose to stop at first error, or continue execution of other functions, see the list of all failed ones, fix them and start them again using the Data Upgrade – Resume… action.
You can see that the data from the upgrade table was successfully transferred into the new table.
Now since our data is sitting in its right place, now we can remove objects we are using for Upgrade purpose.
Now the data upgrade is completed and we need to remove the objects used within that process.
Force-delete the upgrade table, since the data was already transferred into the new table.
Delete the upgrade codeunit to make sure the old synchronization instructions defined in it are not used by the NAV server when you decide to change the My Sales Customer table again. Alternatively (if you want to reuse the upgrade codeunit later) you can choose to change the type of the GetTableSynchSetup function to “Normal”.
Now we are done with our Upgrade project.
This set of demonstrations have provide you the insight, new way of running the data upgrade in Microsoft Dynamics NAV 2015 by involving the schema synchronization and upgrade codeunits.
The new approach:
Business Applications communities