Operating State
ADITO distinguishes between two system state types that can be read through system variables:
- operating state via
vars.get("$sys.operatingstate") - record state via
vars.get("$sys.recordstate")
Both variables return one of the following string values:
VIEWNEWEDITSEARCH
When checking these values in code, do not compare against the raw strings. Use the corresponding constants instead:
neon.OPERATINGSTATE_VIEWneon.OPERATINGSTATE_NEWneon.OPERATINGSTATE_EDITneon.OPERATINGSTATE_SEARCH
The same constants are used for both operating state and record state. There are no dedicated constants for record state.
Operating state and record state are closely related, but they describe different scopes:
- Operating state describes the state of the current Context.
- Record state describes the state of a record or even part of a record.
Example:
If you are in a MainView and use the pencil button of a component, the Context remains in operating state VIEW, while the corresponding part of the record is already in record state EDIT.
Another example:
If you are in an EditView, both the operating state and the record state are EDIT because the entire Context and the record are being edited.
In most cases, use $sys.recordstate to determine whether data is currently being edited, because the operating state may still be VIEW while the record state is already EDIT. Use $sys.operatingstate when you need to know whether the current Context itself is an EditView.
Example:
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null )
{
result.string(util.getNewUUID());
}
Figure: Example of a valueProcess that presets an ID for a new record. In most cases, this is not required because the system handles it automatically.