The previous article showed how to use collections of log statements to document and report a Flow's execution. After reading this article, you will be able to
- Build a Flow Audit using Text Templates
- Understand the difference between Collections auditing and Template auditing
- Implement Flow Audits faster and with fewer pieces to manage
Collections Auditing
As we saw in the last article, Flow Audits use a combination of Flow variables, assignment statements, and SightLane-specific components to easily insert monitor content exactly where it is needed, at exactly the right time.
While this creates detailed and highly specific monitoring content, it can also require the creation of numerous formula fields. For example, if you want to log a numeric value, Salesforce Flow rules require you to create a separate Flow Formula to combine the number and the descriptive text, before adding it to the audit. For complex Flows with a lot of monitoring content, this can result in dozens of formula fields that must be added to the Flow and then to the monitor.
On many occasions, monitor content is more static and less dependent on decisions within the flow. For example, a monitor designer may just want to "write out" a pre-determined collection of variables and records at the end of the Flow. In these cases, there is an easier way to create descriptive log statements without all the formulas and concatenation.
Text Template Auditing
Enter template auditing. Using this technique, SightLane monitor designers create a single Text Template in which all monitor content is defined simultaneously. Better still, Text Templates support merge fields, so there is no need for custom formula field creation! Just write it once and log it every time. Let's see how this is done.
To begin, add a Text Template variable to your Flow and create all the content you need for your monitor, as shown below. Notice that you can combine text, merge fields, and formulas together into one seamless experience.
An important note with Text Templating is that you must add a "delimiter" (any character or set of characters) to the end of each line to separate the statements. If you skip this step, your whole monitor will be returned as one big line instead of separate log statements (and it doesn't look very pretty!)
Remember not to use a character that is likely to come up in the content of your logs (For example, a comma or a period may not always be the best choice). Using the "View as Plain Text" option for your Text Template is strongly recommended.
Reporting Text Template Monitors
Now that the template is set up let's report the Event to SightLane. For this, use the same SightLane components (Report an Event to SightLane and Report a Failure to SightLane), with a small change to their setup. When leveraging a Text Template, use the "SightLane Log" and "SightLane Log Delimiter" fields instead of the "SightLane Logs (Collection)" field. Also, be sure to set the delimiter field to the same character that was used in your text template (in this example, a comma).
And that's it! Your new monitor will render exactly as you planned without the need for creating lots of formulas! Check out your new and simpler monitor results from the SightLane Control Center.
Collections vs. Templates
In the previous article, we described another way to create Flow auditing data (logging) using a Collections variable rather than a Text Template. There is no "right way" to choose your implementation strategy, and it is perfectly fine to mix and match strategies depending on the situation.
For example, in Flows that only need final results saved to SightLane, you might use a Text Template, which is easier to implement. For Flows that require custom tracking or that might traverse the same social path multiple times, using a Collections variable, which can result in more customized content, may be more appropriate.
Finally, note that if you are using Platform Events to report Flow auditing data to SightLane (an advanced and optional technique), you must use the Text Templates approach. This is because Platform Events have no way to accept a collection of Strings and require that the Event content be passed as a single (hopefully delimited) variable. If this makes your head spin, don't worry about it! We'll get to those more advanced techniques in a later article.
Summary
Creating SightLane monitors using Text Templates is a great way to simplify your monitor-building process while still getting the results you need. Combining text with existing variables and formulas will help you create great monitor results quickly! Experiment with these tools, and be sure to let us know what you think at support@sightlane.com
Happy Monitoring!