web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / OlisterR's NAV/BC blog / Client Management in Busine...

Client Management in Business Central using AL Code

Olister Rumao Profile Picture Olister Rumao 3,967

Introduction:

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.


Pre-requisites:

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

References:

Demonstration:

ClientType:
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:
MemberDescription
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
    CU_ClientManagement.GetCurrentClientType

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

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

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

    end;
}

Conclusion:

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. :) 



Comments

*This post is locked for comments