- 16 Feb 2025
- 2 Minutes to read
- Print
- DarkLight
- PDF
Add functions to a Dynamic Document
- Updated on 16 Feb 2025
- 2 Minutes to read
- Print
- DarkLight
- PDF
Add functions
You can add arithmetic functions into a section. For example, you may want to include a function that calculates the price after a discount for a certain item.
In some cases, you can insert aggregate functions that calculate the sum total when there are multiple instances of the same function. For example, if you have a function called item_price that is used in more than one instance, you can insert an aggregate function that will calculate the total of all the item_price functions.
Limitations to using functions
The type of functions you can add to a section depends on what type of section you are adding them to. Sections that are bound to a Form behave differently to unbound sections. Binding a section of a Dynamic Document to a Form is used when building a visual cart. The following table summarizes the type of functions you can add to a section and what those functions can include:
Bound Section | Unbound Section | |
Function | Function can include:
| Function can include:
|
Aggregate Function | Not available | Aggregate function can include other functions from anywhere in the document. |
Add a regular function
To add a regular function to a Dynamic Document:
In the toolbar of the relevant section, click the Add Function button.
In the dialog box that opens, click Create New.
The Create Function window appears.Enter the name of your function, for example item_price.
In the function box, enter the function itself.
In bound sections, you can use the add function button or the add attribute button to include attributes and functions that are used in this section.
In unbound sections, you can use the add function button or the add aggregate function button to include functions and aggregate functions from anywhere in the document.
For example, you can write the following function to calculate the price after a discount, that includes 2 attributes.
@document.price - @document.discount
Click Save to save the new function.
Click Save to save the new function .
To add the new function into the section, click the Add Function button again and select the function you just created.
To edit or delete the function, click the relevant buttons next to the selected function.
Add an aggregate function
Click the Add Aggregate Function button.
In the dialog box that opens, click Create New.
In the Create Aggregate Function dialog box, in the title box, enter the name of your aggregate function.
In the function box, enter the function itself.
You can use the add function button to insert a function from anywhere in the document.For example, you can write the following aggregate function to calculate the total of all the item_price functions:
item_price + 0
Click Save.
To add the new aggregate function into the section, click the Add Aggregate Function button again and select the function you just created.
To edit or delete the aggregate function, click the relevant buttons next to the selected aggregate function.