Hi Readers,
Business Central gives you a facility to perform certain operations while you upgrade the extension i.e, changes were made to your extension and you would want to publish it. This can be done with the help of an Upgrade codeunit. There are operations that can be performed while you modify an extension and want to check something at that time.
Some of the examples can be updating version of an app, modifying records in a table, inserting value to a field if a new field was created in the extension.
How to create it?
For a codeunit to be of type 'Upgrade', you need to define the SubType.
These are the triggers:
OnCheckPreconditionsPerCompany() and OnCheckPreconditionsPerDatabase():
Used to check that certain requirements are met before the upgrade can be run.
OnUpgradePerCompany() and OnUpgradePerDatabase():
Used to do the actual upgrade.
OnValidateUpgradePerCompany() and OnValidateUpgradePerDatabase():
Used to check that the upgrade was successful.
Note: Upgrade codeunit will trigger when we Publish our extension for the second time with updated version id.
Example:
Scenario:
A new version of the extension wherein you want to remove any special characters from the Customer name. Following is the code:
Update it by increating the version: app.json > “version”: “2.0.0.0”
1. Online Sandbox:
VSCode > AL:Publish without debugging (Ctrl+F5)
2. Online Business Central Production:
>Web client > Extensions Page >Upload .app file
Thank you!
ReplyDeleteDo check other blogs if you haven't already!
SMB ERP Solution is a Microsoft Silver Partner. We provide Supply Chain Management Solutions, Microsoft NAV, Microsoft Dynamics NAV, Microsoft Dynamics Business Central. Contact us info@smb-erpsolutions.com for more details. Check out our website for more detials- Dynamics NAV Upgrade
ReplyDelete