The Computed Field property is a feature that allows you to perform calculations using data from Dynamics 365. It’s a way to automatically calculate values based on other data in your system, without having to manually perform the calculations yourself.
The following article describes how to set up a computed field for your template.
Step-by-step description
Step 1: Open a Word template and navigate to the ❶ DocumentsCorePack TemplateDesigner and open the ❷ Insert MailMerge Fields.Step 3: The Computed Field properties window opens.
A calculation pattern can be created in the ❶ Property Designer or the ❷ Text property designer. In the Property Designer, you can enter ❸ a field either by double-clicking on the tree view or by ❹ searching for it. Clicking on the plus (+) button or right-clicking within the pattern will bring up a context menu where a ❺ number, ❻ operator, or ❼ function can be added. Fields can be dragged and dropped where appropriate.There are five available functions to add, as outlined below:
- Floor: This function rounds down to the nearest integer value for a given number. Please keep in mind that when rounding down for a negative number, this results in a larger negative number. For example, when applied to 5.25, the function will return 5, whereas when applied to -5.25, it will return -6.
- Ceil: The ceiling function is the opposite of the floor function and will round up to the nearest integer value for a given number. Please keep in mind that for negative numbers, this function would result in a smaller negative number. For example, when applied to 5.25, the function will return 6, whereas when applied to -5.25, it will return -5.
- Sqr: The square function returns the given integer squared. For example, 4 returns 16.
- Sqrt: The square root function returns the square root of the given integer. Please note that the given integer cannot be a negative number. For example, 4 returns 2.
- Trunc: The truncate function cuts a number to the specified number of decimal places without any rounding. For example, applying “5.25,1” will yield “5.2”, “-5.25,1” yields “-5.2”, and “5.25” assumes zero decimal places and yields “5”.
In the Text property designer, formulas can be entered manually (see below).
Note: If the formula isn’t displayed correctly, you can enlarge the window to ensure clear visibility of your input.
Example: In the following example, we want to find out discount percentage. The formula is using parentheses to ensure that the calculation is done correctly.
Result:
Note: Please keep proper mathematical syntax in mind. In the following example, the parenthesis have been removed, leading to the incorrect result.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.