Document
A document definition is the blueprint for the JSON documents that are created when creating new cases in Valtimo. It defines the structure of the case and contains validation rules for the data that is stored by the actual JSON documents that are created when executing processes for that case in Valtimo. This page shows how to create a document definition, and how to add validation to properties.
Creating a document definition
There are two ways of creating new document definitions in Valtimo.
- Import a case definition, see here. 
- Create an empty case via the UI - Place a valid JSON schema in the codebase via an IDE 
 
Create an empty case
Available since Valtimo 13
- Go to the - Adminmenu
- Go to the - Casesmenu
- Click on Create 
- Enter the name, version and description, and optionally edit the key 
- Click on Save, this takes you to the case definition overview 
- Click on the Document tab to see the document definition 

The chosen title will be validated and based upon the title a read-only case definition key will be generated. This is to create a unique identifier for that case definition without spaces or special characters. Click the Save button to create the case with the chosen title. The case definition is created and the case details page is displayed upon completion. A valid empty JSON schema is created with the title and id based on the given title.

#### Place a valid JSON schema in the codebase
To create a document definition, the following steps are necessary:
- Create a document definition file (ending with - .schema.document-definition.json) under the following path:- */resources/config/case/{case-definition-key}/{version-tag}/document/definition/. The name should correspond with the ID of the document ID. The ID itself should end with- .schema.- {% code title="person.schema.document-definition.json" %} - { "$id": "person.schema", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Person", "type": "object", "properties": { } }- {% endcode %} 
- Properties as well as validation rules can be added to the definition as per the JSON schema standard as seen here. Below is an example of what this definition could look like. - {% code title="person.schema.document-definition.json" %} - { "$id": "person.schema", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Person", "type": "object", "properties": { "firstName": { "type": "string", "description": "The person's first name.", "maxLength": 15 }, "age": { "description": "Age in years which must be equal to or greater than zero.", "type": "integer", "minimum": 0 }, "birthday": { "description": "Birthday", "type": "string", "format": "date" }, "hasPet": { "description": "Has pet.", "type": "boolean" } } }- {% endcode %} 
Editing a document definition
Same as for creating cases there are two ways of editing document definitions.
- Edit the document definition directly via the UI. 
- Edit the document definition in the codebase via an IDE. 
Edit the document definition
- Go to the - Adminmenu
- Go to the - Casesmenu
- Select the case that you want to edit 
- Click on Edit 
- Edit the document definition as per the JSON schema standard 
- Click on Save 

Visually nothing happens when switching to edit mode. Only the Download and Edit buttons are replaced by a Cancel and a Save button. The Save button is disabled by default until valid changes are made.
Constant validation
In edit mode, the UI editor will constantly validate the JSON file structure. The Save button is only available when the JSON structure is valid. Errors in the file structure will be indicated with a red curly line below or near the issue. In large files, errors can easily be found with the minimised tree view on the right side of the editor.

Edit the document definition in the codebase
Open the document definition in the IDE and edit the definition as per the JSON schema standard. More information on JSON schema can be found here.
The location of the document definitions in the Valtimo Java/Kotlin backend: */resources/config/case/*/*/document/definition
Changes will only be available in the application once the changes have been deployed via the CI/CD pipeline.
Please note
Changes to document definitions have immediate effect on newly created cases based on this document definition. Changing this file means changing the blueprint that is used to validate each case that is created in Valtimo based on this blueprint. Changes will have impact, so create backups when unsure of the result.
Access control
Access to document definitions can be configured through access control. More information about access control can be found here.
Resources and actions
com.ritense.document.domain.impl.JsonSchemaDocument
assign
Allows assigning users to a case document.
assignable
Allows users to be assigned to a case document.
create
Allows creating of a case document.
claim
Allows claiming of a case document.
delete
Allows deleting of a case document.
modify
Allows modifying of a case document.
view
Allows viewing of a case document.
view_list
Allows viewing of case documents.
com.ritense.document.domain.impl.JsonSchemaDocumentDefinition
create
Allows creating of a case document definition.
delete
Allows deleting of a case document definition.
modify
Allows modifying of a case document definition.
view
Allows viewing of a case document definition.
view_list
Allows viewing of case document definitions.
Examples
Last updated