GetEnvironment Method

Gets information about the environment that the control add-in is using. For more information, see Control Addin Object.

Method signature

object Microsoft.Dynamics.NAV.GetEnvironment()

Return value

Returns an object that contains the following members:

Member Description
UserName Type: String

The name of the user that is logged into the Dynamics 365 Business Central service.
CompanyName Type: String

The name of the company that the current user is using on the Dynamics 365 Business Central service.
DeviceCategory Type: Integer

An integer indicating the type of device that the control add-in is being rendered on. Possible values:

0 – Desktop client, either Dynamics NAV Client connected to Business Central or Business Central Web client.

1 – Business Central tablet client.

2 – Business Central phone client.
Busy Type: Boolean

A boolean indicating whether the client is currently busy. The client could, for example, be busy performing an asynchronous call to the server.
OnBusyChanged Type: Function

A function that is called when the Busy state of the client has changed.

Function Syntax

The syntax of the function is the following:

function callback()
Platform Type: Integer

An integer indicating the underlying platform that the control add-in is being rendered on. Possible values:

0 – Dynamics NAV Client connected to Business Central.

1 – Business Central Web client, Business Central tablet client, or Business Central phone client in a browser.

2 – Business Central Mobile App.

3 - Microsoft Office add-in.
UserInteractionMode Type: Integer

An integer indicating the user interaction mode that the control add-in is being rendered under. Possible values:

0 - Mouse

1 - Touch

Example

This code example illustrates how you can assign members of the object return type to variables and use the Busy member to determine whether the client is busy or not.

var environment = Microsoft.Dynamics.NAV.GetEnvironment();  
  
var userName = environment.UserName;  
var companyName = environment.CompanyName;  
  
environment.OnBusyChanged = function()   
{  
    if (environment.Busy) {  
        // The client is now busy.  
    }  
    else {  
        // The client is not busy anymore.  
    }   
}  
  

See Also

AL Method Reference
InvokeExtensibilityMethod Method
GetImageResource Method