valueProcess
When the valueProcess is executed
The valueProcess or displayValueProcess of a field is executed to provide a value in two cases:
- The EntityField is not linked to the RecordContainer
- The current record state is
OPERATINGSTATE_NEWorOPERATINGSTATE_EDIT
valueProcess and displayValueProcess run after the loading of the RecordContainer has been executed and might be evaluated separately for each dataset. These processes therefore require particular care, because they can cause significant performance issues when the logic is complex or many rows are involved. Whenever possible, calculate the value or display value in the RecordContainer instead.
Preselection
When creating or editing a record, the valueProcess can be used to preset or update the value of an EntityField, for example with the current date and time for a field of content type DATE:
import { datetime, neon, result, vars } from "@aditosoftware/jdito-types";
if(vars.get("$this.value") == null && neon.OPERATINGSTATE_NEW == vars.get("$sys.recordstate"))
{
result.string(datetime.date());
}
Figure: Example of a valueProcess used for presetting a date value.
This example includes a condition that limits the calculation to the creation of a new dataset and only runs while the field has no value yet.
Variable dependencies
When a valueProcess or displayValueProcess loads a JDito variable with vars.get(), it creates a dependency on that variable. When the source variable changes, the dependent EntityField may be recalculated if necessary. For more details, see Understanding Variable Dependencies.