Inkey Solution Logo
banner

Blogs

Schema Update Mode in AL code for Dynamics 365 Business Central

, July 23, 2021 8512 Views

Description: 

This blog will describe the significance of the Schema Update Mode and why it is used in Business Central. We were facing some issues while working on the table extensions and realized that we could not change the data type or the size of the custom fields we described in the extension once published.

Document Objective

  • Importance of using Schema Update Mode in Dynamics Business Central
  • To educate about the error we were facing and how we resolved it.
  • Different options in Schema update mode
  • SchemaUpdateMode : ForceSync
  • SchemaUpdateMode : Recreate
  • SchemaUpdateMode : Synchronize

Problem:

In Business Central if once we create a table extension and insert some custom fields in the extension once the extension is published and at a later stage, we realized that the data type or the size of the field is not as expected and want to change it. Business Central usually throws an error denoting that the changing of the data type of fields is not allowed.

Error:

The Solution:

If we ever realized that we need to make some changes in the fields (may be the data type and size of the fields) after we publish the extension then we can use the “SCHEMA UPDATE MODE” in the launch.json file.

Update Schema Mode consist of 3 options i.e.:

  • Synchronize

  • Recreate

  • ForceSync

  • SchemaUpdateMode : ForceSync

We can set the Schema Update mode to ForceSync, by default the Schema update mode is set to Synchronize. ForceSyncis very similar to the existing ‘Synchronize’ schema update mode but with more freedom to make schema changes while retaining data. Data will be preserved in almost all cases. The only exception is changing the main table’s Primary Key in which case the data from the extension tables will be lost.

Field renames and changing of datatypes and sizes are allowed and supported in this mode, but the data can only be preserved if we maintain the same ID. If we change both the name and the ID of the field than data will be lost.

  • SchemaUpdateMode : Synchronise

The default value for schemaUpdateMode is set to the Synchronize mode, i.e. every time we publish an extension to the sandbox instance, the data we would’ve entered previously will be there in the schema. If we do not want to synchronize the sample data with each publish, we can simply change the schemaUpdateMode setting from Synchronize to Recreate.

  • SchemaUpdateMode : Recreate

When we set the schema update mode to Recreate, all the tables and table extensions are recreated at every publish, which means that all the data in those tables are lost. This means that we will get empty records when we publish our extension every time we make some changes in the extension.

To change the schemaupdate mode to Recreate, follow these simple steps, open the launch.json file. Insert the syntax at the end before the curly braces are closed i.e.

“schemaUpdateMode”:”Recreate”

Hope this helps

 


ATM Inspection PowerApp to ease ATM inspection and report generation process.
https://www.inkeysolutions.com/microsoft-power-platform/power-app/atm-inspection

Insert data into Many-to-Many relationship in Dynamics CRM very easily & quickly, using the Drag and drop listbox.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/drag-and-drop-listbox

Comply your Lead, Contact, and User entities of D365 CRM with GDPR compliance using the GDPR add-on.
https://www.inkeysolutions.com/microsoft-dynamics-365/dynamicscrmaddons/gdpr

Create a personal / system view in Dynamics CRM with all the fields on the form/s which you select for a particular entity using the View Creator.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/view-creator

mm

Inkey

INKEY is your solution partner.
Our focus is to deliver you in-time intelligent innovative solutions ("key") for the problems in hand. Maintaining a quality standard right from the inception of a project is our top most priority.

Our team of talented professionals will execute your projects with dedication and excellence. We take ownership and accountability for the effort that goes into meeting our client’s needs.

Years of experience and proven success of delivering innovative custom solutions.

More posts by

Leave a Reply

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

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Drop file here

Would you like to digitize your business and put it on the cloud?
Do you need clear, concise reports for your organization?