App variables
App variables is a data source available in every app for storing global app state. App variables contains a number of built-in variables and you can also add your own.
These variables can be bound to properties in UI components and action nodes, and referenced in conditions and filters.
Custom app variables
Custom app variables are used to store app state for a given instance of the app. For example, you might need to store a boolean value to track if a component is visible or not, or a datetime value for filtering recently created objects in a list.
App variables are runtime variables, which means that they exist only in the user's browser and are not saved to the database or shared with other users. An app variable will be cleared each time an app is refreshed, unless the Persistence property is populated.
Properties
Name
The name used throughout Appfarm Create to refer to this app variable. This name can be changed at any time without technical consequences.
Node Name
The key that is used to store the property in memory.
Data Type
The type of data allowed to be stored in this property. See data types.
Cardinality
If the Data Type is set to a reference to an Object Class or an Enumerated Type (see data types), you have the option to define Cardinality. The default is One, but you may also select Many (storing an array of references instead of a single reference). Read more on the Cardinality setting in the Object Class Properties section here.
Property Type
An app variable can be either be value or a function.
Value
: A primitive value that can be read and updated.Function
: A function that calculates a value at runtime. For example, a function that generates a random number between 1 and 100.
Value on Create
Available for Value property type. A default value to set for the property when the app is loaded.
Function
Available for Function property type. A function that calculates and returns a value at runtime.
Label True
Available for Boolean data type. A text label to display when the value is true. See boolean labels.
Label False
Available for Boolean data type. A text label to display when the value is false.
Label Undefined
Available for Boolean data type. A text label to display when the value is undefined (empty) or null.
Persistence
Specify if the value should be stored in the user's browser. There are three options:
None
: The value will not be stored and will only exist in the current instance of the app. This is the default behavior.Local Storage
: The value will be stored in the browser's local storage. It will remain there until the user logs out of the app or the login expires. When the value is stored, it will be available for use the next time the app is loaded. If the user has the app open in multiple tabs, the value will be available to all tabs.Session Storage
: The value will be stored in the browser's session storage. It will remain there until the user closes the tab, the user logs out of the app, or the login expires. When the value is stored, it will be available for use the next time the app is loaded.
For more information about local and session storage see the MDN Web Storage API documentation.
Description
A longer description of the app variable. For your own reference.
Built-in app variables
The built-in app variables contain standard information about an app while it's in use, such as the active environment or client screen size. Some of these variables are based on built-in enums which can be incorporated into your object classes.
Active Currency
Enum
The currency of the Active Language added under Internationalization. For example, Euro
or United States Dollar.
Active Environment
Enum
The environment the end-user is using, either Develop
, Test
, Staging
, or Production
.
This variable can be useful to alter functionality based on if the active environment uses production data (Staging and Production) or not.
Active Language
Enum
The language the app has applied, based on those added to the solution under Internationalization. For example, English
or Norwegian
.
App Time Zone
Enum
The time zone the app is operating in. By default the device time zone is used, but it can be overridden. Calendar data sources are based on this value.
Example: Your App has functionality for registering new Events in Norway, with Start and End time. You want to make sure that the start and end time is "Norway time" when your end users are working remote from Asia.
The solution is to set App Time Zone fixed for your App (or based on the Event's location). It may be done with a simple Update Object in the On App Load action (setting App Time Zone to Europe/Oslo
)
Client IP
String
The end-user's IP address.
Client Screen Size
Enum
The screen size of the end-user's device, either Large
, Medium
, Small
, or Extra Small
.
This variable can be useful to show/hide UI components based on the available screen real estate.
Device Orientation
Enum
The current orientation of the end-user's device, either Portrait
or Landscape
.
Device OS
Enum
The end-user's device operating system.
Device OS Version
String
The end-user's device operating system version.
Document Title
String
The HTML <title> tag. By default, it is the name of the app as specified in App Settings. Shown in the browser's title bar or in the page's tab.
This variable can be useful to change the page title dynamically. E.g. you may update this property using an Action with an Update Object action node.
Hostname
String
The solution hostname for the environment the end-user is using. Given a solution with the short name showroom
and all environments available, the following hostnames could be returned:
- showroom-dev.appfarm.app
- showroom-test.appfarm.app
- showroom-stage.appfarm.app
- showroom.appfarm.app
This variable can be useful to generate the URL for your app based on the active environment, for example when using the Send email action node.
Is Fullscreen
Boolean
If an app has been installed as a Progressive Web App and is running in fullscreen.
Is Main Drawer Open
Boolean
If the Main Drawer property is set in App Settings and the drawer is open.
Is Online
Boolean
If the app is currently connected to the server.
Is Unauthenticated
Boolean
If the user is not logged in and using unauthenticated access.
Notification Permission
Enum
Holds information on whether the user has granted or denied permissions for notifications from this app on this device. The default is Prompt
, i.e. the user has not granted or denied permissions. The other possible values are Denied
or Granted
. The value is changed when the action node Request Permissions is executed, and the value is reset when permissions for the app are reset in the mobile app settings or browser settings.
Last updated
Was this helpful?