Skip to main content

Client Management in Business Central using AL Code


Have you ever got into a requirement, where you are needed to actually execute the logic separately for different client types?

Well, this blog is just going to discuss the ClientType DataType and different ways of getting ClientTypes and how to use it in your code.


  • Microsoft Dynamics Business Central Online
  • AL Language Extension
  • VS Code



In order to understand how to use ClientTypes, we need to understand what ClientTypes represents.
ClientType is an Option based DataType introduced in Business Central. That is in order to get the value or use the value we need to simply use just like ClientType::<Option Value>

ClientType has the following OptionMembers:
BackgroundA background client.
ChildSessionA child session client.
DesktopA desktop client.
ManagementA management client.
NASA NAS client.
ODataA NAS client.
PhoneMicrosoft Dynamics Business Central Phone client.
SOAPA SOAP client.
TabletMicrosoft Dynamics Business Central Tablet client.
WebMicrosoft Dynamics Business Central Web client.
WindowsMicrosoft Dynamics Business Central Windows client.
CurrentMicrosoft Dynamics Business Central Windows client.
DefaultThe default client.
ODataV4A ODataV4 client.
ApiAn API client.

Applying ClientType:
In this code, I will explain how to select a specific Client Type in AL Code.
There are two ways of selecting the Client Type.
1. Using Client Type Management Codeunit: The syntax will be

2. Using CurrentClientType function: Just like using 'CurrentCompany' standard function, you can use the CurrentClientType function

 trigger OnOpenPage();
    CU_ClientManagement: Codeunit "Client Type Management";
    ClientType_1 : ClientType;
        If CU_ClientManagement.GetCurrentClientType() = ClientType_1::Api then begin 
            Message('API Client Type');

        If CurrentClientType = ClientType_1::Background then begin 
            Message('Background Client Type');



In this blog, we covered what is ClientType DataType and how to use it to find what is the ClientType of the logged-in session.

I have personally discovered this datatype and found out the different ClientTypes that were added recently.

I hope this helps you get a clear understanding, implications, and how to apply it. :) 


Aske Holst said…
No need to create a ClientType_1 variable, Enum values can be directly accessed as Enums are static.

trigger OnOpenPage();
CU_ClientManagement: Codeunit "Client Type Management";
If CU_ClientManagement.GetCurrentClientType() = ClientType::Api then begin
Message('API Client Type');

If CurrentClientType = ClientType::Background then begin
Message('Background Client Type');

Thanks agreed.
I also wanted to also demonstrate the datatype as well.

Popular posts from this blog

Understanding and How to use APIs Business Central - 2

In my last blog post (Business Central API -1 ) on Creating API in Business Central, we discussed all the commonly used properties of the page, query, and controls like field and data-item. In today's blog, we will be diving deeply into the validation of the data passed through the API endpoint, how it enters into the source tables and is manipulated to be inserted/modified into single or multiple tables.
Also, I will be demonstrating how APIs are to be used.

Microsoft Dynamics Business Central (SaaS)VS Code( Language Extension( V1 from Business Central On-Premise DVD
Books & References:
API V1 from Business Central On-Premise DVDAPI(V1.0) for Business Central (Click Here)API(Beta) for Business Central (Click Here)
Understanding API in Business Central 1. BINDSUBSCRIPTIONS: Use to trigger IntegrationEvent for the Codeunit stated in parameters whenever the function calling BI…

Creating APIs in Business Central - 1

While writing a blog on Automated Testing in Business Central, I was going through sample apps provided by Microsoft and realized that the complexity is nowhere close to what examples Microsoft has provided on In this blog, I will try to explain how APIs work and how to be creative with the implementation. Also, an API which were in beta are finally out with version V1.0 in the April 2019 release let's see some important key things from development aspects.
This blog is going to be theoretical one kindly bear with me.

Microsoft Dynamics Business Central (SaaS)VS Code( Language Extension( V1 from Business Central On-Premise DVD
Books & References:
API V1 from Business Central On-Premise DVDAPI(V1.0) for Business Central (Click Here)API(Beta) for Business Central (Click Here)

Key Requirements:
API source table must have an Id(GUID) field per record for m…

Enum Object in Business Central - How to create and how to extend!

Since the dawn of Business Central Era (2nd April 2018 - Today), there are many new data types introduced by Microsoft.
One such data type is Enum(Enumeration). Essentially, what enumeration is having a single select value with multiple options at a given time!
Well, I know what your thinking what about the 'Option' data type.
Anyways, enough of talking let's just dive in!

Disclaimer:The knowledge in this blog is true and complete to the best of authors and publishers knowledge. The author and publisher disclaim any liability in connection with the use of this information.
Microsoft Dynamics Business Central (SaaS or On-Premise)
VS code with AL Language extension

1. Enum as an Object:
Just like Tables and Pages, Enum behaves like an Object.
Note that Extensible means that the Enum Object can be extended in another module. By default, this property is set to TRUE.

Enums and Enum Extensions behave differently. They follow a different number se…