Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Calculated merge fields allow you to use a scripting language to perform calculations. Creating calculated merge fields is an advanced topic and requires a reasonable understanding of computer programming.
A Calculation Merge Field is used when you need to add a new field to a document that is based on a calculation of existing fields. For example a field to show the volume of an object based on fields that contain its width, height and depth.

Creating a new calculated merge field:

  1. Click the New Merge Field hyperlink at top of the Merge Fields screen.
  2. Give it a field name that you will use in your template documents. This cannot have any spaces it in so use the "_" character instead of a space in the name. You can also optionally give it a description as well - this can be entered as normal text.
  3. Tick Repeat Field if required, and specify Initial and Final Separators.
  4. After you Submit your new Merge Field, you will then need to click the Edit Calculation hyperlink to return to the Edit Merge Field screen shown below.
  5. Click the Edit Calculation hyperlink to then add the underlying code to perform the calculation. This will be done using PHP code in combination with the custom data fields that are defined within the Action type you are wanting to use this calculation in.
  6. To get the list of variables (existing custom data fields), use the drop down list to first select the Action type and then use the List button to display the list of variables, as shown below.
  7. Insert the code for the calculation combining the existing variables with the required math function. You can test the calculation at any time by entering an Action ID for an action with valid custom data then clicking Test. The results are displayed in the lower RESULTS: box.
  8. Once you are happy with your code Save the calculation and then Submit your new Merge Field.

Example

An example of how to add GST (goods and services tax) to a simple value is shown below for reference.

Note: The online PHP manual can be found at http://www.php.net/manual/en/

Using Participant Type Custom Data in Calculations

Reference the variables as $pt(Participant Type)(Data Field Name)[Participant Number]
For example to refer to the rate for the first Lead Provider in a matter use $pt_Lead_Provider_Rate[1]
IMPORTANT: Make sure all custom data fields are filled out for each participant you want to reference - if it is only partially filled out then the calc might not work.

  • No labels