Links

Enumerated types

An enumerated type, or enum, is a set of key-value pairs used to define constant values in a solution. Enums can be added as object class properties and referenced directly from within apps and services. As well as defining your own enums, you can access a number of built-in enums.

Usage

To add an enum to your data model:
  • Hover over the + icon in the bottom-right of the data model designer.
  • Click Create Enumerated Type.
A typical use case for an enum is to store possible State values for an object, such as Planned, In Progress, and Complete.
As an example, an Event object class might need a property to track if an event has occurred or not. The value of this property can be one of a set of fixed values.
To store these values you can create an enum called Event State with three enum values. The values can be given the display names Planned, In Progress and Complete. Once the Event State enum is created, you can add a State property to the Event object class, with the data type Event State, tying the enum to the object class.
Enums are suitable for properties where you want to retain full control of the possible values. Within your apps, you can build conditions and filters bound to such properties, for example a Text Edit component that is visible if Event.State EQUALS Planned. You can also see examples of how to use enums in functions.
Enum values are often exposed in the UI using the Select component, enabling the user to view the available options and make a selection.
Example
An enumerated type example is available under UI Templates in our Showroom. Click on Dialog - New Issue. In the dialog that opens, Category is populated by an enum. Don't have access? Register.

Properties

Property
Description
Name
A descriptive name for the enum.
Data Type
The data type of the enum values. This property becomes read only after enum values are added. The options are:
  • Auto: Each enum value is assigned an automatically generated value. This option should be selected in most cases.
  • String: Each enum value can be assigned a custom string.
  • Integer: Each enum value can be assigned a custom integer.
The string and integer types are useful if the values should be readable, or if you are integrating towards external systems with existing values that the solution needs to understand.
Description
A longer description of the enum. For your own reference.
Tags
Add tags.
Enum Values

Enum values

Enum values are the key-value pairs, or available options, within an enum.
Property
Description
Display Name
The label to display in the UI. This name is also used to refer to the enum value throughout Appfarm Create.
Value
The value to store in the database when this enum value is chosen, in the format selected under Data Type. If the data type is Auto, this value will be automatically generated and read-only.
Icon
An icon from the built-in icon library to represent the enum value. The icon can be displayed in the UI, such as in a List, Table or Map.
Color
A color to represent the enum value. The color can be used to style the color of the Icon (see setting above) or it may be used for defining the color or the (grouping) category of Charts. Example: Product Category is an Enumerated Type with different color for each Enum value. A graph displaying sales per product category may have the color of each data series in the graph controlled by the Enum color of each Product Category.
Dark Theme Color
A color to represent the enum value when a dark theme is applied. If not specified, Color will be used.
Description
A longer description of the enum value. For your own reference.

Built-in enums

Appfarm has a set of built-in enumerated types. These can be referenced in the same way as a normal enum, but the values can not be changed. The built-in enums are used for app variables and service variables.
Enum
Description
Appfarm Environment
The four environments: Develop, Test, Staging, and Production.
Device Orientation
The two possible device orientations: Portrait and Landscape.
Device OS
A set of possible operating systems: Android, iOS, iPad OS, Mac OS, Windows and Other.
Language
The languages added to the solution under Internationalization. For example, English and Norwegian.
Object State
The synchronization state of an object: New, Updated, and Synchronized.
Screen Size
The four possible screen sizes: Large, Medium, Small, and Extra Small.
Theme
The themes added to the solution under Themes.
Time Zone
World timezones. For example, Australia/Melbourne.
View
The views in the active app.