Default values and prefilling
For definition properties, it is possible to add a 'default value' or 'prefill data' when creating the related entity.
This feature does not apply when updating an entity, only when creating a new one.
You can read more about this feature Default values and prefillinghere (in the portal's public documentation).
Below is described only what is not available to the public user.
Creating a new entity on the backend side
The public documentation (linked above) states that the 'default value' feature is displayed to the user on the frontend and is also applied by the backend. If a new entity is created outside the UI, such as through an API, SDK, or migrations, the backend will also supply default values. To avoid applying default values to the properties of a new entity, set the property value to 'null' in the new entity object.
How the feature works
By creating an entity on the frontend, we essentially send the entity object we want to add to the backend. From now on, the action of "creating a new entity" will be considered as "sending an entity object to the back end." For each property type, a valid value type is sent.
An example of a new element where the "default value" will not be applied
{
"plainText": "test value",
"richText": {
"ops": [
{
"insert": "test value"
}
]
},
"list": [
"test value 1",
"test value 2",
"test value 3"
],
"date": 1773100800000,
"file": "test file id",
"number": 12345,
"entitySingle": "test entity id",
"entityList": [
"test entity id 1",
"test entity id 2",
"test entity id 3"
],
"link": {
"text": "test title",
"link": "test link value"
},
"checkbox": true,
"phone": "+380999999999",
"email": "[email protected]",
"json": {
"testProperty": "test value"
}
}In order for a 'default value' to be applied to a property, you need to specify the value of 'undefined' for that property in the entity object, or not specify that property in the object at all (equivalent to the value 'undefined')