S-Docs templates support arithmetic functions for both static numbers and numeric fields. All functions should be written using standard Salesforce math operators. S-Docs will evaluate all functions using the standard mathematical order of operations.
To use arithmetic functions in your S-Docs templates, simply enclose the function within <MATH> tags.
The following example uses both static numbers and numeric fields.
To format the result of your arithmetic function, use the format-number attribute within the <MATH> tag as shown below, but not within the merge fields.
You can also use date fields or static dates within your arithmetic functions. The two main types of date math supported are:
- Adding/subtracting time from a date
- Evaluating days/months between dates
Both types of date math require the use of the type="date" attribute within your <MATH> tag.
To add or subtract days, months, or years from any date field, use the following syntax (where X equals the number of days, months, or years you would like to add or subtract from the value of the date field):
Evaluating Time Between Dates
To evaluate the time between two dates, use the following syntax:
To format the result of your arithmetic date function, use the format-date attribute within the <MATH> tag as shown below, but not within the merge fields.
When using arithmetic functions in DOCX templates, be sure to enclose the entire function within square brackets, as shown in the following example.