Your place for snippets of useful Dynamics NAV and Dynamics 365 Business Central information.

Menu

Determining the right client

In certain scenarios, it may be important to know what client that the user is working in. Perhaps you have an action that doesn’t work in the Web Client, or maybe you have some code that interacts with a device camera that only works in the Device Client. Or maybe you want to send a link to your users that allows them to open a record, and we want to make sure the link is for the correct client?

First, I want to be clear that what I am describing here is based on the Dynamics NAV 2017 platform. Yes, this means the Dynamics 365 for Financials platform falls under this umbrella as well. Perhaps bits and pieces are supported on older platforms, but my intention is to never look backwards and keep this train moving forward!

Now to it…

There are some system variables that we need to get familiar with:

CLIENTTYPE

an option variable that contains the various client types:

Windows

Web

SOAP

OData

NAS

Background

Management

Tablet

Phone

Desktop

ODataV4

CURRENTCLIENTTYPE

Returns the client type that is currently executing the code.

DEFAULTCLIENTTYPE

Returns the default client type, as defined in the Dynamics NAV Server configuration. For more information click here.

Example 1: Show an action only in the Windows Client.

In the Development Environment, design the page that contains the action.

Make sure that the action does something. If it does not do anything, then it will always be hidden. For testing purposes you can add the following code to the onAction trigger for the action:

MESSAGE('A message for testing');

Add a global Boolean variable named ‘showMyAction’:

Assign the global variable to the Visible property of the action that you wish to conditional show/hide (you can show this property as a column in the Action Designer now!!):

Add the following code to the onOpenPage trigger:

showMyAction := CURRENTCLIENTTYPE = CLIENTTYPE::Windows;

Close, save and compile your page.

If you run the page in the Web Client for example, you will not see the action on the ribbon of the page. Running the page from the Windows Client will show the action.

Example 2: Create a url that takes a user to the first customer record.