With AODocs, you can set up conditional logic in document classes in any type of AODocs library. When users edit their documents, 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)
Conditional logic is calculated using formulas that can include references to other entities such as custom or system properties, custom property states (mandatory or hidden) and the document title.
Before you use this article, you should:
- be familiar with the basics – learn more: What is conditional logic in AODocs?
- know how to set up conditional logic in the library configuration to:
Use this article alongside the article Create your own formulas: use the correct JavaScript syntax for conditional logic to learn how to be creative with your conditional logic according to your specific business needs.
Learn about JavaScript syntax:
Automatically generated table of contents
JavaScript format of custom property values
Simple properties
Use this reference: propertyType`Name
of your property`
where Type
is one of these simple property types:
- String/Text
- Boolean
- Integer
- Decimal
- Date, DateTime, Time
The table below indicates the format of the JavaScript values for each simple property type.
Note: Simple properties don't have elements (fields) such as .name
, .type
.
AODocs |
JavaScript |
Examples: AODocs property |
String/Text |
String |
JavaScript value: |
Boolean |
Boolean |
JavaScript value: |
Integer |
Number (integer) |
JavaScript value: |
Decimal |
Number (float) |
JavaScript value: |
Date DateTime Time |
Number (integer) |
JavaScript value: (number of milliseconds since January 1, 1970, 00:00:00 UTC) |
For example, use the formula:
'The document : “' + systemPropertyString`Title` + '” of the project: “' + propertyString`Project name` + '“, version: ' + propertyInteger`Version number` + ' has been validated.'
to obtain the following calculated value in your "Status" String property:
Note: Learn how to handle properties without values (empty properties).
Properties with an object representation
The following properties have richer information and are represented by objects in JavaScript:
- Person
- Category
- URL
- Geopoint
JavaScript objects have elements (fields).
The table below indicates the format of the JavaScript Person object with its elements.
Person element |
JavaScript object: type and example |
What does it do? |
value |
JavaScript object: String
propertyPerson`Approver`.value
|
Displays the email address of the approver |
type |
JavaScript object: String
|
Displays the type of email address:
|
displayName |
JavaScript object: String
|
Displays the name of the user account or the Google group, for example: |
The table below indicates the format of the JavaScript Category object with its elements.
Category element |
JavaScript object: type and example |
What does it do? |
id |
JavaScript object: String
|
Displays the category value ID, for example: |
name |
JavaScript object: String
|
Displays the category value, for example: |
shortName |
JavaScript object: String
|
The category value short name, for example: |
outdated |
JavaScript object: Boolean
|
|
level |
JavaScript object: Integer
|
Index of the last level of the category structure that is filled in; starts at 0. For example, if "US/Nevada" is filled in for the "Location" category with the structure "Country/State/Town", the value is |
levelName |
JavaScript object: String
|
Name of the last level of the category structure that is filled in. For example, if "US/Nevada" is filled in for the "Location" category with the structure "Country/State/Town", the value is |
leaf |
JavaScript object: Boolean
|
For example, for the "Location" category with the structure "Country/State/Town", the value |
path |
JavaScript object: Array of category objects See example below. |
The array represents all the values that are filled in, from level 0 (in the example below, EMEA) to the last level filled in (Paris). All category objects must have a |
Below is an example of the path of a multi-level category.
{ |
|
Examples of formulas that reference Category properties:
- "Type of Contract" is a single-value Category property with one level. Each value has a short name, for example, the category value "Services" has the short name "SV".
Use this formula to display the short name as the calculated value of your String property:propertyCategory`Document Type`.shortName
- "Location" is a single-value Category property with three levels: Country (path[0]), State (path[1]), City (path[2]). Use this formula to display the State as the calculated value of your String property:
propertyCategory`Location`.path[1].name
Note: If your category value is empty at the level defined (in this example, if the State level of the Location property is not filled in), an error occurs. Learn how to handle properties without values (empty properties).
Format of the URL object
The table below indicates the format of the JavaScript URL object with its elements.
Category element |
JavaScript object: type and example |
What does it do? |
uri |
JavaScript object: String
|
Displays the URL, for example: |
displayText |
JavaScript object: String
|
Displays URL display text, for example:
|
Format of the GeoPoint object
The table below indicates the format of the JavaScript GeoPoint object with its elements.
Category element |
JavaScript object: type and example |
What does it do? |
latitude |
JavaScript object: Decimal
|
Displays the latitude value, for example: |
longitude |
JavaScript object: Decimal
|
Displays the longitude value, for example: |
Note: Learn how to handle properties without values (empty properties).
Multi-value properties
Multi-value properties are represented as arrays. Each item of the array is represented as a mono-value of the property type. Also, Multi
is added to the entity reference.
Example 1:
Use the formula:
propertyMultiString`Suggestions`.length
to count the suggestions in your audit CAPA report listed in the multi-value String property named "Suggestions". The property "Number of suggestions" shows the calculated value 3.
Example 2:
Use the formula:
propertyMultiCategory`Product type`.map(a=>a.shortName).join(' - ')
to concatenate the short names of all the values of the multi-value category property named "Product type".
Handle property values that are empty or that have missing elements
If your formula references a property that isn't filled in (it's empty) in your document, the property with an empty value is handled as follows:
- mono-value properties: empty values are represented as
null
Note: A Boolean property is empty if it hasn't yet been edited. When edited for the first time, it becomes either true
or false
.
- multi-value properties: the empty values are represented as an empty array
[]
Note: We recommend referencing only mandatory properties in your formula. However, you may want to handle empty properties within your formula if, for some reason, you don’t want to make the property mandatory or if documents are created by importing from Gmail, for example, and an approver hasn't been defined. Learn more:
– Create documents from emails in Team Folders and Secured Folders (in Gmail)
– Create documents from emails in Document Management libraries (in Gmail)
Example 1: empty properties – replace default with specific text
You created a String property whose value is calculated. Its formula references two properties. If either or both of these properties is empty, their values are null
in the result.
Use this formula to replace null
by specific text. In this example, if the property "Published by" has a value, its displayName
is used in the property "Internal publication code"; if the property "Published by" is empty, the text "No publisher defined" is displayed.
|
Example 2: missing short names in category values
You created a property whose value is calculated. Its formula references a Category property using the element .shortName
. Learn more: Format of the Category object
Some of your category values may not have short names. To ensure errors don't occur when you calculate your property, write a formula that displays the short name if it exists and displays the category name if the short name doesn’t exist.
Use this formula:
propertyCategory`Type of Contract`.shortName
? propertyCategory`Type of Contract`.shortName
: propertyCategory`Type of Contract`.name
|
|
Example 3: missing short names and empty properties
You created a property whose value is calculated using the element .shortName
. Use this formula to handle the case where the property is empty and where some of your categories don't have short names. In this example, if the Category property "Type of Contract" has a value, its short name is used; if it doesn't have a short name, the name is used; if the property is empty, the text "Default" is used.
propertyCategory`Type of Contract`
? (propertyCategory`Type of Contract`.shortName
? propertyCategory`Type of Contract`.shortName
: propertyCategory`Type of Contract`.name)
: 'Default'
Example 4: missing value and empty category in multi-level category
For the "Location" Category example above, use this formula to replace any missing State values or empty values with "No location".
(propertyCategory`Location` && propertyCategory`Location`.path[1]) |
Example 5: missing value in Category properties
You created a String property named “Please, specify”, which you want to be displayed only when a user selects the value “Other“ in the Category property “Location”. You also want to handle the case when no location value is selected, which means the “Location” property is empty.
You can make the “Please, specify” property conditionally hidden with the following formula:
!(
propertyCategory`Location`
? (propertyCategory`Location`.id
=== categoryValue`Location:Other(Sb04Uwg000000V5flG)`)
: false
)
You can also use the JavaScript optional chaining operator ?.
– learn more: Optional chaining. This returns the ID of the value selected in “Location” (if any) and otherwise returns undefined
without triggering an error:
!(
propertyCategory`Location`?.id
=== categoryValue`Location:Other(Sb04Uwg000000V5flG)`
)
JavaScript format of system property values
System property values have a simple JavaScript format.
The table below indicates the format of the value for each system property.
System property |
Description |
Syntax to reference the system property |
id |
String The ID of the document |
|
stateID |
String The ID of the workflow state |
|
creationDate |
Integer (Epoch milliseconds) The date-time at which the document was created |
|
title |
String The title of the document |
|
stateChangeDate |
Integer (Epoch millisecond) The date-time at which the document last changed workflow state |
|
Extract the year, month and day from JavaScript dates
Date property values are given in Epoch milliseconds. Learn more: Simple properties.
To extract the year, month or day from a date, add to your formula a function that “transforms” the Epoch milliseconds into a JavaScript Date and then identifies the item you want to use.
Example 1: extract the year
'Year' + ' ' + new Date(systemPropertyDateTime`stateChangeDate`).getFullYear()
In this formula:
new Date(systemPropertyDateTime`stateChangeDate`)
transforms the property into a JavaScrip date.getFullYear()
identifies that you want to extract the year
Example 2: extract the month
'Month' + ' ' + (new Date(systemPropertyDateTime`stateChangeDate`).getMonth()+1)
Important: Months in JavaScript start at zero: January is 0, February is 1, and so on. As indicated in the example, you need to add +1
to the result of the .getMonth()
function to get the correct month number!
Note: By default, single-digit months in JavaScript don't have a leading zero. If you want August (for example) to be 08 and not 8, use:(new Date(systemPropertyDateTime`stateChangeDate`).getMonth()+1).toString().padStart(2,'0')
Example 3: extract the day
'Day' + ' ' + new Date(systemPropertyDateTime`stateChangeDate`).getDate()
JavaScript format of other AODocs entities
The three sequence IDs (library, document class and document) are given as strings.
Learn more: Sequence IDs.
Category values and workflow states are given as simple IDs (Strings). For example: RzziPGBu6KcCb8C3oT
.
Learn more: