Overview:
Performing such operations as adding dates or calculating minimum and maximum values is possible with user-defined jScript or C# functions.
Solution:
To add a user defined function, the Manage Scripts button located in the Template group under the Review tab must be selected.
The Manage Scripts dialog is displayed, where functions can be inserted.
For a better understanding, an example of a jScript function that adds number of days to a date is provided below.
1. First, an XML file must be assigned to the template document. The following sample has been used for this example:
2. The Manage Scripts dialog must be displayed in order to insert the following jScript function that adds a number of days to a date:
function DateAddDays(date, addDate)
{
var d = new Date(date);
d.setDate(d.getDate() + addDate)
return d.toLocaleDateString();
}
3. Then, the Field button located in the Dynamic Content group under the Insert tab must be selected and the following text inserted into the Expression field:
js:DateAddDays(string(/root/Date), 4)
Design View:
Print Layout: