Constants

Last modified: August 20, 2024

Introduction

Constants are used to define configuration values. These can differ per environment.

When running the application on a licensed Mendix Cloud environment, SAP BTP, or Private Cloud you can configure the constant values for each environment separately using the Model Options tab of the Environment Details page to set your constants.

For other cloud environments – for example, Siemens Insights Hub – the constants can be accessed as Environment Variables in, for instance, Cloud Foundry. The constant is exposed with the name module + . + constant (for example, mymodule.myconstant).

When running the application locally or in a Free App environment, the values defined in Studio Pro are used.

Constants can be used in the following:

  • Expressions – by prefixing the full name of the constant with @
  • Consumed web services – in this case, the constant is a URL that specifies where the web service is located; this can vary based on the environment in which the application is running, so that you can, for example use different web services for development and production

Common Properties

Name

The name of the constant. This name is used to refer to it.

Export Level

Export level allows you to define access level to this document on the consumer (customer) side when developing an add-on module or a solution.

Value Description
Hidden (default) The document/element content is hidden from a consumer.
Usable Consumers can see the constant and use it in their app.

Documentation

This field is for documentation purposes only: end-users will never see it, and it does not influence the behavior of your application

Type Properties

Type

The data type of the constant. This determines what kind of values a constant can hold. Supported data types are string, Boolean, date and time, decimal, and integer/long.

Value Properties

Default Value

This property is the default value of the constant. This value is used when running locally or in a Free App environment. When running locally, the value can be overridden in the currently selected configuration.

Exposed to Client

This property defines whether the constant is accessible from client-side expressions (expressions in nanoflows and pages).

Option Description
Yes The constant will be sent to the client and will be accessible from client-side expressions
No (default) The constant will not be sent to the client and will be only accessible from microflow expressions