Hi, Readers.
This week, I found an interesting question on Twitter. Although it already had an answer. I’d like to talk a little more about the details.
Question:
![](https://yzhums.com/wp-content/uploads/2021/02/image-469.png)
![](https://yzhums.com/wp-content/uploads/2021/02/image-470.png)
So in this post, we will discuss how to get the client type that is running in the current session via AL code.
First let’s take a look at Client Type in Business Central.
ClientType Option Type: Represents the type of the client executing the operation.
![](https://yzhums.com/wp-content/uploads/2021/02/image-471.png)
Memebers:
Member | Description |
---|---|
Background | A background session. |
ChildSession | A child session. |
Desktop | A desktop client. |
Management | A management client. |
NAS | A NAS client. |
OData | A NAS client. |
Phone | Microsoft Dynamics Business Central Phone client. |
SOAP | A SOAP client. |
Tablet | Microsoft Dynamics Business Central Tablet client. |
Web | Microsoft Dynamics Business Central Web client. |
Windows | Microsoft Dynamics Business Central Windows client. |
Current | Microsoft Dynamics Business Central Windows client. |
Default | The default client. |
ODataV4 | A ODataV4 client. |
Api | An API client. |
Teams | Microsoft Teams client. |
Then, there is a method.
Session.CurrentClientType Method: Gets the client type that is running in current session.
For example: Show the client type when open Item list page.
![](https://yzhums.com/wp-content/uploads/2021/02/image-459.png)
Browser:
![](https://yzhums.com/wp-content/uploads/2021/02/image-460-1024x426.png)
Phone:
![](https://yzhums.com/wp-content/uploads/2021/02/image-458.png)
Teams:
![](https://yzhums.com/wp-content/uploads/2021/02/image-463-1024x598.png)
![](https://yzhums.com/wp-content/uploads/2021/02/image-457-1024x598.png)
Business Central Windows 10 desktop app:
![](https://yzhums.com/wp-content/uploads/2021/02/image-462-1024x588.png)
![](https://yzhums.com/wp-content/uploads/2021/02/image-461-1024x592.png)
So what can we do more with client type?
Similar to the question at the beginning, we can use this function to specify each client type’s program separately.
For example: Item Description can only be modified in the web client.
![](https://yzhums.com/wp-content/uploads/2021/02/image-464.png)
If you modify it in other client types, an error will be reported.
![](https://yzhums.com/wp-content/uploads/2021/02/image-465.png)
Edit in Excel
![](https://yzhums.com/wp-content/uploads/2021/02/image-466-1024x592.png)
![](https://yzhums.com/wp-content/uploads/2021/02/image-467-1024x571.png)
![](https://yzhums.com/wp-content/uploads/2021/02/image-468.png)
Test Video:
END
Hope this will help.
Thanks for reading.
ZHU
コメント