Reference
The reference field is used to refer to a field value in another document. It allows administrators to create dynamic models where updates to referenced documents are automatically reflected in the reference field value. References can be made to documents in other document definitions or within the same document definition.
Properties
| Property | Required | Purpose |
|---|---|---|
| Reference Type | Yes | Specifies whether there are references to one or more documents. For references to a single document, select the one-on-one (1-1) option. For references to multiple documents, choose the one-to-many (1-N) option. |
| Document Definition | Yes | Specifies the document definition to refer to. Note that it's not possible to remove a document definition if it's referenced by another document definition. |
| Reference Label | Yes | Defines the label to be displayed for the options in the reference list. BizzStream text expressions can be used for dynamic labels. For example: {{F["name"]}} - {{F["code"]}}. |
| Filter | No | Filters the list of options available to the user based on a BizzStream filter expression. For example, only show documents with a particular status. |
| Search Method | Yes | Specifies how the user can search the options. It can be set to "contains," "starts with," or "ends with." |
| Sort Field | No | Determines the sorting order of the options presented to the user. The options are sorted based on the selected field's values within the referenced document. |
| Sort Order | Specifies whether the sorting order is ascending or descending. | |
| Validate Reference Field | No | Determines whether to validate only the reference fields that have been updated when saving the document. This option avoids unnecessary validation of all reference fields. |
| When a Related Document is deleted | Yes | Specifies the behavior when a referenced document is deleted. Options are: (1) Prevent deletion, (2) Delete the document containing the reference field, or (3) Delete the reference. |
Tips
The reference field is a very commonly used field. Often reference fields will be automatically filled by a dynamic value. This can be done in the following ways:
- Provide the
_idof the document. E.g.1234567890abcdefinds the document with that _id. - Use a BizzStream expression with a filter to find the correct document. E.g.
FILTER("items","code = 500")finds the document(s) in the "items" document definition for which the code field has value "500".