Value Loaders - Loading Default Values
A Value Loader is used to fetch the value of a property. Value Loaders are typically used for properties that represent a calculated, auto-generated or queried value. A Value Loader can be configured to be executed during every request for the value or only when the value is NULL.
What are Value Loaders?
A Value Loader is used to load the value of an Entity Field on the server side. Value Loaders are used for fields that represent a calculated, auto-generated, or queried value. A Value Loader can be configured to be executed before every INSERT/UPDATE operation or only when the value is NULL.
Note: Value loaders run on the server side only before saving data.
They are not applied on the client side. To have default value loaders on the client side, see Entity Field - Custom Get/Set, Display Value Formatting.
Configuring a Value Loader
To configure a value loader for an Entity Field:
Types of Value Loaders
There are 4 types of value loaders supported in Contineo. The loader type is set in the Value Loader > Loader Type property of an Entity Field.
Following are the configuration settings for each loader type:
1. Static
This is the simplest loader where you can assign a static value to the field.
The default value is to be provided in the Value Loader > Default Value property of the Entity Field.
2. API
This loader requires an Entity API of type Data Loader to be defined.
The loader API is selected in the Value Loader > Loader API property of an Entity Field.
The result of the API is set as the value of the field.
3. Script
This loader requires a loader script to be provided.
The script is entered in the Value Loader > Loader Script property of an Entity Field.
The result of the script, that is, the value of the result variable is set as the field value.
See Value Loader Script Execution for more details.
Example: See the Expected Completion Date field in
XLib.Samples.Todo > Task Entity.
4. Concat
This loader uses a user-defined concatenation rule to build the field value by combining values of other fields.
The rule is defined as a JSON array in the Value Loader > Concat Values List property of an Entity Field. The following is a sample of a Concatenation Rule script:
Example:
[{"field":"Address1"},{"separator":" | ","label":"","field":"City.Name","relational":"true","noValueText":""},{"separator":" | ","field":"State.Name","relational":"true","noValueText":""}]
