Magic "enum"

How does the magic “enum”-feature work?
We can not find any information or examples.

We want to use a enum in a relation. Is there anywhere a good article about using the “enum” in servoy.

Hi,

Define your enum for example in Scopes.globals (to be used in a relation) :
/**

  • @enum {Number}
  • @public
  • @properties={typeid:35,uuid:“69D3E0A0-DCC8-44BC-9222-4CB7F06CE386”,variableType:-4}
    */
    var ENUM_TEST = {
    ENUM_1: 1,
    ENUM_2: 2
    }

So you can add a relation and “scopes.globals.ENUM_TEST.ENUM_1”, “scopes.globals.ENUM_TEST.ENUM_2” will be accessible as source fields of a relation.

Tested in 7.3.1 - build 2022

Hope this help.

madimane:
Define your enum for example in Scopes.globals (to be used in a relation) :

Better create a new scope like scopes.namespaceThatDescribesTheEnumIntention and create your enum in there. Using globals is bad practice.

Thank you deezzub for the globals link.
Very good stuff to take in count!