Hi, Readers.
Today I would like to briefly share a question I was asked recently, how to check whether the current environment (Tenant) is a trial environment via AL. They want to set different limitations for different types of environments.
Okay, first of all, it is possible. We’ve discussed this issue similarly before, let me talk about it again for the trial environment (Tenant).
This time we need to use codeunit 2300 “Tenant License State”. (Exposes functionality to retrieve the current state of the tenant license)
All methods in this codeunit:
For this requirement, we can simply use the following methods.
procedure IsTrialMode(): Checks whether the current license state is trial.
procedure GetLicenseState(): Gets the the current license state.
Tenant license state types:
For example,
Or
Very simple. Give it a try!!!😁
PS:
1. Using this codeunit, you can also get the period, start and end dates of the environment.
Source Code:
pageextension 50100 CustomerListExt extends "Customer List"
{
trigger OnOpenPage();
var
TenantLicenseState: Codeunit "Tenant License State";
TenantLicenseStateEnum: Enum "Tenant License State";
TenenatLicenseInfoMsg: Label 'Tenenat License State is ''%1''\Period is ''%2''\Start Date is %3\End Date is ''%4''';
Period: Integer;
LicenseState: Text[20];
StartDate: DateTime;
EndDate: DateTime;
begin
LicenseState := Format(TenantLicenseState.GetLicenseState());
if TenantLicenseState.IsTrialMode() then
Period := TenantLicenseState.GetPeriod(TenantLicenseStateEnum::Trial);
if TenantLicenseState.IsPaidMode() then
Period := TenantLicenseState.GetPeriod(TenantLicenseStateEnum::Paid);
StartDate := TenantLicenseState.GetStartDate();
EndDate := TenantLicenseState.GetEndDate();
Message(TenenatLicenseInfoMsg, LicenseState, Period, StartDate, EndDate);
end;
}
2. What is Dynamics 365 Business Central viral trial ???
3. How to check and extend your trial period (Only for trial environment)
4. Dynamics 365 Business Central trial FAQ
Update: Check whether the current environment (Tenant) is a Partner Sandbox via AL
END
Hope this will help.
Thanks for your reading.
ZHU
コメント