With AODocs, you can automatically calculate the following elements in your documents:
- calculated properties: values of any type of custom property
- calculated settings, which make custom properties mandatory or hidden
- calculated titles
Note: Calculated settings are currently in private beta. To request access to the private beta, reach out to us: email@example.com.
These elements can be calculated using formulas that can include references to other elements, thereby creating dependencies between your properties, settings and titles. Library administrators can create calculated elements in any type of library.
Examples of use cases:
- Create a calculated property named "Value Added Tax" to calculate the VAT automatically when a user enters a value in the "Price of product" property.
- Create a calculated property named "Publication date" which records the date when the document is transitioned to "Published" by workflow action.
- Automatically calculate the titles of your documents with a formula that concatenates the "Project name" and "Creation date" properties – learn more: Create and configure calculated titles
- Display the property "Describe your issue" and and make it mandatory if the user enters "Yes" in the property "Do you want to report an issue?" (currently available only in private beta)
This article outlines the basics of calculated elements and introduces how to use the library administration to create and edit the formulas on which they're based. After getting to grips with the basics in this article, you can learn more about the formulas used in calculated elements:
- Getting started with formulas for calculated elements – implement simple use cases with code examples you can copy
- Add entity references to your formulas – learn about the syntax of the entity references you can add in the formula builder
Advanced users can get creative and write their own formulas for calculated elements:
In this article:
|Calculated elements: the basics|
|Create calculated elements|
|Edit calculated elements|
|Known limitations and restrictions|
Calculated elements: the basics
What can I use in my formula?
In your formula, you can use:
- values from the document on which the formula will run:
- custom property values, for example, the value "Contract" for the property "Type of document"
- system property values, for example, the document's title or creation date
- sequence IDs for the library, document class or document – learn more: What is the sequence ID?
- current version properties: name, description, creation date
- constant values from the library configuration:
- category values, for example, the value "France" listed in the category "Country" defined at the library level
- workflow states, for example, "Published" in the "Document publication" workflow
Learn more: Add entity references to your formulas.
"Full" versus "simplified" syntax
When you select AODocs entities to use in your formula, entity references are inserted into the formula. A simplified human-readable form of the syntax, based on property names, is used in the formula builder. This makes it easier to understand and write formulas when you're working in the formula editor.
The full syntax stored and used by AODocs is different from the one you see on screen. Behind the scenes, AODocs translates the simplified entity references back into the full syntax, which includes the ID of the AODocs entity.
This means that:
- you can change property names without impacting the formula
- there's no need to shorten property names because the limit of 2000 characters is not based on property names, but on the full syntax
Create calculated elements
Important: Don't combine calculated properties with custom scripts.
Note: This section shows how to create a calculated property, but the formula builder is the same for all calculated elements.
2. You can:
- configure calculated titles
- configure a calculated property: follow the procedure to create a new property, then in the Create a new property pop-up, activate the switch Calculate the value of this property.
3. Press Write formula.
4. In the formula builder, enter a formula in the field.
You can select the following entities to use in your formula:
- Custom properties from the document:
– in the left panel, select From document > Properties and then press the required type of property, for example, String/Text, Date, Category
– in the right panel, choose from the properties of the selected type available in your document
- System properties:
– in the left panel, select System properties
– in the right panel, choose the require system property
- Sequence IDs from the document:
– in the left panel, select From document > Sequence ID
– in the right panel, choose the required sequence ID
- Category values from the library:
– in the left panel, select From library > Category values and then press the required category
– in the right panel, choose from the category values defined at the level of the library
- Workflow states from the library
– in the left panel, select From library > Workflow states
– in the right panel, choose the required workflow state
Note: Current version properties can only be added manually.
- Add entity references to your formulas
- What's the difference between category values in properties and category values defined at the library level?
To use properties in your formula, they must already be saved. If you have created one or more properties and haven't yet saved them, they're not available in the formula builder.
If you enter the name of a property that doesn't exist, an error message appears immediately in the formula builder.
5. Press Create.
6. Press Save.
– If the syntax of your formula is invalid, you can't save the calculated property and an error message opens. This includes invalid cycle dependencies, for example, if you try to save calculated property 1 that depends on the result of calculated property 2, which itself depends on the result of calculated property 1.
– When a property is calculated, AODocs detects valid dependencies and executes the actions in the correct order.
Learn more about how end users use calculated properties in their documents: Edit custom properties
Edit calculated elements
1. In the document class settings in the library administration, expand a calculated property to display its full information.
Note: Calculated properties can't be mandatory and are always read-only. You can't modify these two fields. However calculated properties can be hidden.
2. Press the pencil button under Formula. The formula builder opens.
3. Edit your formula and press OK.
4. Press Save.
Note: If you didn't define a property as calculated when you created it, you can't define it as calculated in the user interface once you have saved it. This can be done only by API.
Known limitations and restrictions
There are currently some limitations and restrictions to calculated properties:
- Information about related documents and attachments isn't available in the formula.
- Don't combine custom scripts with calculated properties because the order of execution is not guaranteed. This is a permanent restriction.
Note: We’d love to receive your feedback on calculated elements! Create a feature request in our Community.