Triggered Fields are a different type of calculated field that adds flexibility and speed to your apps. Why use them? For Calculated Fields, each time a view or table is loaded, all the calculations run. This can affect the performance of your application, especially when you begin accumulating more data or your formulas and tables gain complexity. Triggered Fields allow you to run your calculations when you save a record, which allows you to tailor your applications to perform calculations only when needed. Just like Calculated Fields, Triggered Fields can be found in the list of available fields on the edit table page.
Triggered Fields
When to use Triggered Fields:
1. Retrieving data from a child table (if it isn't a calculated field referencing a parent)
2. Using the {{OLD}} function (see the Complete List of Functions article)
3. If you need to reference an application user field
4. Anytime you don't need to do any of the following restrictions
When can't you use Triggered fields:
1. Retrieving data in a parent field
2. Using the now() or today() function
When do Triggered Fields actually recalculate?
Simply opening a record and clicking Save does not, by itself, cause Triggered Fields to recalculate — you need to actually change a field's value for the trigger to fire.
Exception: bulk editing. When bulk editing records, you don't need to change any field values — clicking Save alone is enough to cause Triggered Fields to recalculate across the records being bulk edited.
My Triggered Field seems to have stopped working — what do I do?
Triggered Fields can stop recalculating if an underlying update to the table's schema failed partway through for some reason. If you run into a Triggered Field that no longer seems to be firing on save, contact TrackVia Support
Calculated Fields
Calculated Field Example:
Let's review a scenario when you should continue to use Calculated Fields.
Your app requires calculations that run on demand when you open your views or records (i.e. calculations based on time functions like NOW() or TODAY() ). Every time you open a view or form, the calculation will be done at that exact moment guaranteeing accuracy.
As an example, let’s say you perform maintenance on your company assets. When you log into TrackVia at 8:00 AM every morning you would like to see which assets are due for maintenance today. First, take your Last Maintenance Date and add 90 days to it - that will be your Maintenance Interval. If that date is equal to Today or it is overdue, you would like to know.
The moment the last maintenance date for the asset is updated, the record will get pushed 90 days into the future and will show up in your queue on that date.
Calculated Field Formula:
if(dateadd({Last Maintenance Date},{Maintenance Interval},"d") >= Today(), "Maintenance Is Required","No Maintenance Needed")
Triggered Field Example:
On the other hand, some applications need to run very large and computationally intensive functions, but these functions only need to run when a record is saved or a child record is added. These types of calculations can leverage Triggered Fields.
A good example is when you have line items that roll up to an invoice. The order total needs to be calculated only when you save the invoice. Because all the sales calculations for the line items will have taken place beforehand, using a Triggered Field to calculate the total invoice value will increase app speed when running reports and opening records related to your sales numbers.
Triggered Field Formula:
sum({Line Items}.{Link to Invoice}.{Line Item Price})
Related Articles:
Comments
0 comments
Please sign in to leave a comment.