Dynamics 365 Business Central: how to check if your Extension is running on a trial tenant

An interesting question in an insider talk some days ago was how to check from AL code if my extension is running on a trial tenant or in a licensed tenant (paid).

After a bit of searching inside our lovely C/SIDE, I’ve found the solution to the question: in Dynamics 365 Business Central there are two useful objects useful for that scope:

  • Table Tenant License State (2000000189)
  • Codeunit Tenant License State (2300)

The License State table contains details of your tenant license such as Start Date and End Date and the State of your license (that is an option field with the following values: Evaluation,Trial,Paid,Warning,Suspended,Deleted,,,,LockedOut ).

To test if this works (and how it works), I’ve written a small function in AL:

CheckD365BCLicense_00.jpg

If you call the GetPeriod method of the Tenant License State codeunit by passing the option value for the state that you need to check, you have as return the remaining days for that state. This function returns -1 if your tenant license is not in the state you have as input.

For example, this is what I have if I run this code in a trial Dynamics 365 Business Central Tenant by calling the GetPeriod method with 1 as parameter (State = Trial):

CheckD365BCLicense_01.jpg

If I call the GetPeriod function with 2 as input parameter (State = Paid) this is the return:

CheckD365BCLicense_02.jpg

This could be a quick and easy mode to test if your extension is running in a trial tenant.

P.S. I suggest to Microsoft folks to add in the Tenant License State codeunit also other methods to retrieve for example the start and ending date of a license (or a state) without making a query on the Tenant License State table.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s