Skip to content
Michael Kolodner edited this page Dec 11, 2022 · 28 revisions

This package installs an object (DashboardTarget) for storing target numbers for dashboard Dynamic Gauge components.

Use and Function

Without DashboardTargets (or something similar), if you want to use dynamic gauges you need to either base them on a number that already exists on a particular record elsewhere in your Salesforce instance or use some other workaround. Dynamic gauges are based on records, not on metadata. There are use cases where you might already have records, such as a campaign with a "Revenue Goal" field. But in thinking it through I don't think most of the gauges you would want to make dynamic will have records you can point them to.

With DashboardTarget you have a convenient place to create records for any gauges. The object is built to allow for either manually created and maintained records or records that are automatically updated.

Manual Records
Example: "2023 fundraising target."
This is a number that staff arrive at through discussion and is not directly generated from data. It's probably based on looking at this year's or last year's opportunities and then extrapolating about what you would like, what is possible, etc. Using a manual DashboardTarget you can put in the number you settle on and use it on a dashboard. If you change the goal later due to further discussions, all you have to do is change the one record and any dashboards based it on will immediately keep pace.

Auto-Updated Records
Example: "Enrolled Students."
Since students could come and go at any time, you want this record to update itself if/when there are any changes. Then any dashboard gauges based on this number (example: "% of enrolled students with a GPA above 3.5") would automatically readjust the top target when students leave the program.

The DashboardTarget object is relatively simple, with just seven fields to support creating and naming a target, a description, and the SOQL that would be used to auto-update it. There are validation rules to prevent mixing up manually-updated and auto-update records. Note that there is no validation that the values in Object API Name or SOQL Query are valid. If an incorrect object name is in the field then the flow will error when it tries to run the SOQL query. (Having validation that the object API names exist would require a much more complicated implementation, probably with code.)

Installation instructions are here.

Components

In addition to the DashboardTarget object, validation rules, tab, and list view there are two flows to act on DashboardTarget objects:

  1. DashboardTarget_BeforeSave_Update_SOQL_Query - This is a before save record-triggered flow. Because we wanted to have the ability to have a longer SOQL WHERE clause field than 255 characters, this flow works as though the SOQL Query field were a formula. Whenever a DashboardTarget record's Object API Name or SOQL WHERE clause fields are updated it updates the SOQL Query field to keep it up to date.
  2. TEMPLATE_DashboardTargets_Contact_targets - This is an autolaunched flow that gathers all auto-updated records that use the Contact object and runs their SOQL Query to fill their target. This is meant to be launched by some kind of scheduled automation (see #3.) If you have DashboardTarget records that look at other objects than Contact you will want to copy this flow for each object.
  3. NOT INCLUDED: DashboardTarget_Run_object_updates - In the scratch org repo is a flow that you would use to regularly refresh your automatic targets, presumably as a schedule-triggered flow. As built in the repo I put a pause element of zero hours before the flow calls DashboardTargets_Contact_targets so that it runs asynchronously and SOQL Query limits are reset. There is no flow like this included in the unmanaged package as of this writing because it would require the Contact targets flow, above, to be active upon deployment, which we don't want. However, it's a very easy flow to rebuild (see post-install directions.)

Dependency

The automation in this package has a dependency on UnofficialSF's flow component for using SQOL (https://unofficialsf.com/a-graphical-soql-query-builder-for-flow/) which gets automatically installed in scratch orgs based on this repo. If you want to use this project in a sandbox or in production you will need to install that component before installing DynamicGaugeTargets.



Acknowledgments

The idea for developing this project was sparked by my work with the Academy Group.