As a library administrator, you can set up conditional logic in document classes in any type of AODocs library.
This article outlines the basics of conditional logic. After getting to grips with the basics in this article, you can learn more about the formulas used in conditional logic:
- Getting started with formulas for conditional logic – 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 conditional logic:
You can also learn about how end users handle conditional logic in the document editor.
In this article:
Automatically generated table of contents
Conditional logic: overview
If conditional logic is set up in a document class, when users edit their documents in this class the conditional logic is applied as follows:
- property values can be calculated automatically
- properties can be conditionally mandatory or hidden
- document titles can be calculated automatically (in Document Management libraries only)
– You can apply conditional logic to any type of custom property. Learn more: Create and configure custom properties.
– Don't combine conditional logic with custom scripts.
– You can't configure data validation for custom properties whose values are calculated with conditional logic. However, you can configure data validation for custom properties that are conditionally hidden or mandatory – learn more: Configure data validation for custom properties.
Conditional logic is calculated using formulas that can include references to other entities such as custom or system properties, property states (mandatory or hidden) and the document title. In a given document, you can therefore create dependencies between properties and other entities in your library. Learn more: What can I use in my formula?
Examples of use cases:
- Create a property whose value is calculated named "Value Added Tax" to calculate the VAT automatically when a user enters a value in the "Price of product" property.
- Create a property whose value is calculated 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 make it mandatory if the user enters "Yes" in the property "Do you want to report an issue?"
Conditional logic: the basics
Where do I set up conditional logic?
Administrators can set up conditional logic in the library administration.
To set up conditional logic:
2. In your document class:
- configure properties whose values will be calculated:
- configure properties to be conditionally mandatory or hidden
- configure conditional logic to calculate titles
What is the formula builder?
The formula builder allows you to write and edit the formula that you will use to apply conditional logic. The formula builder is identical for all types of conditional logic.
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 and a warning appears at the bottom of the formula builder.
If you enter the name of a property that doesn't exist, an error message appears immediately in the formula builder.
– If the syntax of your formula is invalid, you can't save it.
– When the value of a property is calculated, AODocs detects valid dependencies and executes the actions in the correct order.
– AODocs detects invalid cycle dependencies, for example, if you try to save calculated property value 1 that depends on the result of calculated property value 2 which itself depends on calculated property value 1. In this case, an error message appears and you can't save the document.
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.
What's the maximum number of characters that formulas can contain?
Each formula is limited to a maximum of 2000 characters. If you have a specific business case that requires the limit of 2000 characters to be extended, contact your AODocs sales representative or send an email to email@example.com.
What happens if I try to delete a property referenced in a formula?
You can't delete a property if it's referenced in a formula. An error message appears indicating the formulas in which it is referenced. You must remove the reference in each of the formulas before you can delete the property.
Error indicating that the property "Customer" can't be deleted as it is used in four 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
Known limitations and restrictions
There are currently some limitations and restrictions to conditional logic:
- Information about related documents and attachments isn't available in the formula.
- Don't combine custom scripts with conditional logic because the order of execution is not guaranteed. This is a permanent restriction.
Note: We’d love to receive your feedback on conditional logic! Create a feature request in our Community.