Chin's Musings - Template Formulas

Welcome to another installment of Chin's Musings! In this series, Systems Controller Chin Chuah will create helpful rundowns of various system features and processes to help you better understand the SmartSimple platform.

What are Template Formulas?
Template Formulas provide a method for updating standard/custom field values on an object behind the scenes upon saving. They let you perform extra calculations after saving an object. They can be handy because they let you:
  1. Update an object and perform calculations after it's been saved (i.e. support ticket subjects). Say you want to combine an autonumber field with the Level 1 subject, but when you first create the Level 1 the autonumber hasn't been reserved and stored yet until after you save. (For more information about the Universal Tracking Application and the different Level Entities, read our wiki.)
  2. Affect objects at different levels (i.e. a Level 2 formula can be used to update a Level 1, an Level 1 formula can be used to aggregate its contacts).
  3. Easily perform difficult calculations with MySQL functionality and avoid heavy scripting (i.e. perform business day calculations).
Where can you configure Template Formulas?
The configuration settings can be found on most entities now, such as Universal Tracking Application Level 1, Level 2, Level 3, transactions, contact roles, company categories.

How are Template Formulas used?
You must specify valid MySQL syntax within the settings box, and each line is ended with a semi-colon. Each line is processed sequentially and in order after saving an object.

When do Template Formulas run?
Template Formulas run after an object is saved and uses the newly saved field values for their calculations. They are also chained such that when saving a Level 3 the formulas run in the order of Level 3 global formula, Level 3 type formula, Level 2 global formula, Level 2 type formula, Level 1 global formula, Level 1 type formula. When deleting a Level 3, the formulas for the Level 2 and Level 1 are also run.

Disclaimer
Template Formulas are run by the server, so for performance considerations should not be abused. A Template Formula should only be used when a calculation can not be achieved on the page with calculated value custom fields, or when trying to update a field that does not exist on the page (i.e. at Level 2 you wish to update a Level 1 field).

Learn more about Template Formulas by reading the SmartSimple Wiki. Contact us at info@smartsimple.com or visit our main website  for more information.

Comments

Popular posts from this blog

Introducing 24/5 Technical Support

SmartSimple Attends the Conference Board of Canada’s Corporate Social Responsibility Conference

Dedicated vs. Non-Dedicated Servers – What’s best for me?