How to Migrate Record Links from Business Central On-premises to Business Central Online

The weekend before this post, I was working on a migration from Navision 2015 to Business Central On Cloud (V20.4), and after finishing everything, the client asked about the Record Links that were not showing up, and after investigating discovered that Microsoft does not currently replicate this information.

So, I thought of several ideas, the first one was for the configuration package but this is not possible either.

Later I thought that an option could be to export the table as CSV from SQL and then do an import process in Business Central on Cloud that would allow me to record this information, but I discovered that an essential field of the Record Links is the RecordID which was going to complicate me the conversion from Text.

Finally, I am undecided whether to create Web Services or Use XMLPort, and I decided to use the latter way, which this post will deal with today.

This is the general flow that was used to achieve the migration of the Record Links

Project Overview

Business Central v14

For this migration of Links, use XMLPort to export and another to perform the import of the Records Links. But in the BC140 version, unfortunately, I couldn’t use the Record Links table as it wasn’t available. So I created a clone table that through SQL I could enter the data.

Note: For this step, I had previously used generatesymbolreference since I had to work with other Business Central records and I was able to do it without problems, but I suppose that this error was generated only for system records.

Given the above, I am going to share the objects that were used only in Business Central v14.

Table

The following Table is a Clone of the Record Links table, created in order to be used by the XMLPort

SQL

To populate the new temporary table use the following SQL script.

INSERT 
INTO [DB_NAV80].[dbo].[Records Links Temp$9c054801-914b-4aa7-bb6b-888888888888]
([Link ID],[Record ID],[URL1],[Description],[Type],[Note],[Created],[User ID],[Company],[Notify],[To User ID])

SELECT [Link ID],[Record ID],[URL1],[Description],[Type],[Note],[Created],[User ID],[Company],[Notify],[To User ID]  
FROM  
[DB_NAV80].[dbo].[Record Link];

Note: You must look for the corresponding Table created in SQL of the extension, in my case it was called Records Links Temp$9c054801-914b-4aa7-bb6b-888888888888.

XMLPort for Export

This XML Port uses the Temporary Table created in the extension, which after running the SQL script has exactly the same data.

For the correct export, there is a very important point and it is how to correctly export the RecordID, for this 2 calculated columns RecordPos, and TableID were created, and through the OnAfterGetRecord trigger, we can fill the corresponding values.

Note:

The following image shows an error that only gave me in the On-Premises version when trying to write in the Note field.

To correct it I had to change this line:


"Records Links Temp".Note.CreateInStream(InStream, TEXTENCODING::UTF8);

To this line:


"Records Links Temp".Note.CreateInStream(InStream);

Otherwise, I did not find a way.

The DeleteSpecialChars method is also of great importance since, without it, special characters not allowed were exported when performing the On Cloud import.

Page

This is the page I used for the version of Business Central v14, which uses the Record Links clone temporary table “Records Links Temp”

Once we run the process in Business Central v14 something similar to the following image is seen:

Finally, we obtain a file in CSV format with all the Record Links.

Business Central On Cloud

Now, I will show the code used in Business Central On Cloud to import the CSV file

XMLPort for Import

In the following code on how to perform the import, additionally, I want to detail 3 important points to consider:

  1. To Carry out the correct import of the RecordID for it, with a RecordRef and the previously stored information of TableID and RecordPos.
  1. I was getting the following error in the Notes after inserting: “The data cannot be shown because it is not valid“, the only way to solve it was using the “Record Link Management” Codeunit.
  1. Not so complicated, but I still want to mention, that the user records that come from Business Central On-Premises, bring the windows domain, for example, WORKGROUP\IVAN.LABRADOR, and in Business Central on Cloud, this information is stored without this domain, so it was necessary to perform the delete on each insert using DelStr(UserID, 1, Text.StrPos(UserID, ‘\’))

Pages

The following page is very similar to the Business Central v14 page, the difference is that in the On Cloud version I had no problem reading the Record Links record, and I found it interesting to be able to see the existing records on one page, so I created a different page that also has the following extra actions:

  • Export Record Links: Exports all existing Record Links.
  • Import Record Link: action that will allow us to perform the migration of Record Links exported in Business Central on Premises.
  • Delete All Record Links: currently, the code below and the one I will share on GitHub are disabled, to prevent someone from misusing it, I use it in the sandbox for development.

In the following video, I will show some examples where the Record Links are referenced and then I will export them in CSV format

Now, I’m going to use the delete all Record Links button and then I’m going to import them and verify that everything is still working correctly.

Conclusion

The use of XMLPort proves that it is an incredible tool not only to export and import data between external and internal sources of Business Central but also to migrate some Business Central On-Premises records to the On Cloud version when it is not possible due to configuration pack or complicated

For more information on the use of XMLPorts, I leave you the official link from Microsoft

Important Note:
The code that was created is done assuming that there are no Records Links in the Business Central where the Import is going to be carried out. If it exists, it should be handled slightly differently, calculating the last inserted line and starting from there.

Code on GitHub

All the code used in this post can be found at the following link:

Code

I hope this has been helpful.

2 thoughts on “How to Migrate Record Links from Business Central On-premises to Business Central Online

  1. Dave Machanick Reply

    I have a fix app with a lot of fix procedures.
    For notes, I coped to a custom table, and then in the cloud, copied them back.
    For Record Links, I used an xmlport, and in the cloud, processed the formatted record link to create document links in the new table, and used Azure container to hold the linked files and wrote a program to process them into the new table.
    If a customer has a many gigabytes of files, then they may want to use an external file storage solution like SharePoint or ZETADOCS.

    • ivanrjlg Post authorReply

      Hello Dave,

      I apologize for the delayed response. I just noticed your comment, and I wanted to reach out to thank you for sharing your experience and insights. It’s great to know that you were able to migrate the notes and record links using a custom table, xmlport, and Azure container. Your approach to handling large file sizes through SharePoint or ZETADOCS is also very valuable. It’s contributions like yours that help to enrich the knowledge and solutions shared within the community.

      Thank you again for taking the time to comment on my post.

      Warm regards,

Leave a Reply

Your email address will not be published. Required fields are marked *