The tc:compute tag can add, subtract, multiply, or divide two numeric values, depending on the mathematical operator specified.
When using tc:compute, you must know the following concepts:
•Each value can be either a system field, custom field, or value specified within the template, but they must both be numerical values. Otherwise, TeamConnect will display an error and the document will not generate properly.
•You can nest tc:compute as needed within other tags.
•In order to specify which two values to compute, you nest tags within tc:compute that point to numerical values.
•The tc:compute tag can be described as "Field1 (+, -, *, /) Field2". For example, for subtracting, the second nested field is subtracted from the first nested field. For dividing, the first field is divided by the second field.
The following table describes the tag attributes for tc:compute.
Usage of tc:compute
Tag attribute |
Attribute value |
Description |
method |
"Operator" |
Enter one of the following to specify the mathematical operation between the specified number fields: "+" for addition "-" for subtraction "*" for multiplication "/" for division |
format |
"format" |
Specify the desired number format that will be displayed in the generated document. For a description of possible attribute values, see the description for numberFormat in the Optional Tag Attributes for tc:data and tc:detail table. |
Example: |
<tc:compute method="-" format="###0.00"> <tc:detail select="CLAM/ClaimEstimate" /> <tc:detail select="CLAM/ClaimPaid" /> </tc:compute> |
In the example given, the compute method specified is subtraction "-". CLAM/ClaimEstimate and CLAM/ClaimPaid are number fields for the project Claim. Since CLAM/ClaimEstimate is specified first, CLAM/ClaimPaid will be subtracted from CLAM/ClaimEstimate to give the resulting value in the generated document.
To compute a value from one TeamConnect system or custom field and a value specified within the template, use tc:operand in conjunction with tc:compute. See tc:operand for details.