# Virtual Fields

Virtual fields allow the API user to pass information to certain processing steps performed by the backend. Just like a general field the virtual field is added to the parameters of an operation provided by the 4allportal API. In contrast to a general field the value of a virtual field is completely processed by the 4allportal and is NOT written to the database. Virtual fields are therefore not represented by any columns or tables in the database.

A virtual field is added just like a general field by placing a field configuration in the fields folder of the corresponding module.

# Configuration

A virtual field is created by placing a field config in the fields folder of the corresponding module. The name of a virtual field needs to start with an underscore. For example can a virtual field with the name _myvirtualfield be created for the module account by placing its config at

custom/modules/account/fields/_myvirtualfield.xml

In the field config file the properties of this field are defined. In order to create a virtual field the 'virtual' flag is set to true as the following example shows.


<field>
  <type>CEId</type>
  <virtual>true</virtual>
</field>

Because there are no columns nor tables in the database that represent the virtual field, the following database related configuration values have no effect:

  • default
  • not_null
  • pk
  • unique
  • length

Nevertheless, the general rules for field configurations need to be followed to prevent errors. For example a field from type ce_varchar need to specify a length even if it is virtual. Also, there is no support for dimensions nor for the audit option for virtual fields.

The example config shown above creates a virtual field with the name "_myvirtualfield" (including the underscore) for the account module. This allows to add the virtual field to the parameter values. The following example of a request shows, that a value for the virtual field _myvirtualfield can be passed just like a general field.

  {
  "session": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "method": "set_single",
  "module_name": "account",
  "parameter": {
    "value": {
      "name1": {
        "value": "test"
      },
      "_myvirtualfield": {
        "value": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
      }
    }
  }
}

# Virtual fields of the Core Engine

Virtual fields are generally expected to be processed and removed from the request before the request reaches the core engine. This is typically done by a before hook of the module that creates the virtual field.

Beside these customizable virtual fields, there are virtual fields which are embedded into the core engine. These fields do not need to be explicitly configured by a .xml file. The following list contains all virtual fields supported by the core engine:

Request missing documentation