Difference between revisions of "Template / Type Formula"

From SmartWiki
Jump to: navigation, search
(Using Template/Type Formulas for Text)
Line 91: Line 91:
  
 
==Using Template/Type Formulas for Text==
 
==Using Template/Type Formulas for Text==
If you are using a Template or Type formula to populate a field with text, rather than perform a calculation, you must enclose the statement on the right-side of the equal sign in single quotataions:
+
If you are using a Template or Type formula to populate a field with '''text''', rather than perform a calculation, you must enclose the statement on the right-side of the equal sign in single quotations.
 +
* Any other text, including spaces, will be concatenated to the result:
 +
:
 
  @opportunity.name@='@opportunity.client first name@ @opportunity.client last name@';
 
  @opportunity.name@='@opportunity.client first name@ @opportunity.client last name@';
 
::''Note that the space between the "client first name" and "client last name" variables will place a space between them in the resultant statement.''
 
::''Note that the space between the "client first name" and "client last name" variables will place a space between them in the resultant statement.''
 +
 +
 +
'''Example 2'''
 +
@opportunity.name@='@opportunity.item 1@, @opportunity.item 2@ and @opportunity.item 3@';
 +
::''Would result in a comma and space between the first 2 items and the word "and" between item 2 and 3.''
  
  
 
[[Category:Universal Tracking Application]]
 
[[Category:Universal Tracking Application]]

Revision as of 15:09, 4 June 2009

Level One templates and Level Two and Level Three Types can perform advanced calculations and logic within their Template Formula boxes.

If you wish to perform calculations on fields associated with Level 3, but store the results in fields at the Level 2, you use the Level 2 Formula field. You can use any expression and also some built in functions.

You may also wish to use Template Formulas instead of a Calculated field because the calculations are done server side, rather than by the browser.
Thus if you are doing a calculation on a value that needs to be populate or calculated on the same Level 3 item, this will avoid you having to save twice in order to get the final result.

Template Formualas are calculated when a record is saved.

File:Uta128.png

When you wish to use multiple template formulas, you must use the semicolon to separate them. For example:

@opportunity.totals@=@#123456#@;@opportunity.quantity@=@654321@

Note: Template formulae will only work if the Template standard field is enabled and visible on the page.

Using a Level 2 Type Formula

In order to use this technique in the current example you will need to first enable the duration field in the Level 2 activity.

1. Click Settings.

2. Click Application Configuration.

3. Click the Activity Settings, Standard Fields link.

4. Enable the Duration field.

Uta129.png

5. Click the Save button.

6. Click Settings.

7. Click Activity Settings, Types tab.

8. Click the Addendum type.

9. Scroll to the Level 2 Formula.

Uta130.png

10. Enter the following formula:

Uta131.png

11. Click the Save button.

This expression will be executed any time a Level 3 item is saved.

12. Click the My Actions tab.

13. Click either Level 3 activity type.

14. Click the Save button.

15. Review the associated Level 2 activity.

Uta132.png

  • The duration is set to the sum of the durations of the associated Level 3 entities.
  • The same technique can be applied to the Level 1 Template formula to sum all the Level 2 durations.


Summing Level 2 to Level 1 using field ID:

Go to level 1 template and use the following format @opportunity.#123456#@=@level2.sum(#987763#)@

Summing Level 3 to Level 2 using field ID:

Go to level 2 template and use the following format @level2.#123456#@=@level3.sum(#678954#)@

Summing Level 3 to Level 2 base on a particular level 3 type:

Go to level 2 template and use the following format @level2.#50235#@=@level3.sum(#50291#):eventtype=8866@ where 50235 is the custom field where you want the value to store in, 50291 is the custom field that you want to sum and 8866 is the level 3 type ID,

Note: Currently the system doesn't support summing from level 3 to level 1 using a custom field id. The summing would only work with Amount and Duration field.


Using a Level 3 Type Formula

You can use the Level 3 Type Formula field on the Level 3 Type page in a similar manner as for Level 2.

  • The advantage of using a Level 3 Type Formula instead of a Calculated field is that the calculations are done server side, rather than by the browser.
    Thus if you are doing a calculation on a value that needs to be populate or calculated on the same Level 3 item, this will avoid you having to save twice in order to get the final result.

The following example calculates the product of the values stored in fields named rate and quantity, and saves it in a field called Total with a field ID of 1731330:

@l3.#1731330#@=@level3.rate@*@level3.quantity@

Note: Be sure to use syntax exactly as above. Be sure to use l3 before the equal sign, and level3 after.


Using Template/Type Formulas for Text

If you are using a Template or Type formula to populate a field with text, rather than perform a calculation, you must enclose the statement on the right-side of the equal sign in single quotations.

  • Any other text, including spaces, will be concatenated to the result:
@opportunity.name@='@opportunity.client first name@ @opportunity.client last name@';
Note that the space between the "client first name" and "client last name" variables will place a space between them in the resultant statement.


Example 2

@opportunity.name@='@opportunity.item 1@, @opportunity.item 2@ and @opportunity.item 3@';
Would result in a comma and space between the first 2 items and the word "and" between item 2 and 3.