Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Dynamics 365 Business Central Development Quick Start Guide

You're reading from   Dynamics 365 Business Central Development Quick Start Guide Modern development techniques for Dynamics 365 Business Central

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789347463
Length 224 pages
Edition 1st Edition
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Stefano Demiliani Stefano Demiliani
Author Profile Icon Stefano Demiliani
Stefano Demiliani
 Tacconi Tacconi
Author Profile Icon Tacconi
Tacconi
Arrow right icon
View More author details
Toc

Installing and upgrading codeunits


When you develop an extension, there's also an important aspect to take care of: installation and upgrading operations. When an extension is installed or upgraded, you often need to perform certain operations on data, such as populating new data and restoring existing ones. These tasks can be achieved by writing extension-install-and-upgrade code.

In this type of code, you can access the extension properties (such as version, name, publisher, and dependencies) by using the NAVApp.GetCurrentModuleInfo() and NAVAPP.GetModuleInfo() methods.

The install logic can be written by creating an install codeunit, that is, a codeunit with SubType = Install.

An install codeunit has two main system triggers:

  • OnInstallAppPerCompany(): Includes code for company-related operations. Runs once for each company in the database.
  • OnInstallAppPerDatabase(): Includes code for database-related operations. Runs once in the entire install process.

This is an example of an Install Codeunit...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images