Global ViewModel

The global ViewModel is available in many places in the application and can be used in XTemplates, among other things. It contains important information such as data on the user session, the global date range filter, the selected language, the active module, the user’s roles and rights and the maintenance mode. This centrally managed data enables consistent and efficient handling of application-wide settings and user information

Structure of the ViewModel

Table 1. Attributes of the global ViewModel
Name Description

activeModule

Contains information about the currently active module, including ID, name, etc.

dateRange

Defines the global date range for data filtering with properties such as value, global mode and activity status.

language

Saves the currently selected language of the user interface (e.g. "de" for German).

license

Contains information on various license aspects of the application, modules and services.

maintenanceModeEnabled

A Boolean value that indicates whether the application is in maintenance mode.

monitor

Configuration settings of the monitor module.

right

Defines the user’s access rights to various modules and functions.

role

Contains the roles assigned to the user (e.g. administrator, normal user).

status

The status attribute includes various sub-attributes that provide information about the current status of the application, including CRUD status, active user sessions and license details. These attributes help to monitor the system status and identify problems to ensure smooth functionality.

userSession

Stores information about the current user session, such as login credentials and session duration validity.

uuid

A unique identification number for the current instance or session.

This overview represents the main components of the global ViewModel, but additional attributes and data structures may be present depending on the configuration, application context and specific implementations.

Access via the browser console

To view the current content of the global ViewModel, you can perform the following steps in the browser console:

  1. Open the developer tools of your browser (F12 in most browsers)

  2. Switch to the console

  3. Enter the following command:

    BpcCommon.Api.getGlobalViewModel().get("global")

This shows the current state of the global ViewModel.

Use in XTemplates

When using XTemplates, you can access the global ViewModel.

Example:

new Ext.XTemplate(
  '<p>Aktueller Benutzer: {global.userSession.firstName} {global.userSession.lastName} </p>'
)