-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repo demonstrates creating an object (DashboardTarget) for storing target numbers for dashboard Dynamic Gauge components. Without something like this if you want to use dynamic gauges you need to either base them on a number that already exists on a particular target record (such as a campaign with a Revenue Goal field) or use some other workaround because the dynamic gauges are based on records, not on metadata.
With a DashboardTarget object you have a convenient place to create records for any gauges you will want to create. The object is built to allow for either manually created and maintained records or records that are automatically updated.
An example of a manual record could be "2023 fundraising target." This is a number that staff arrive at through discussion and is not directly generated from data. Using a manual DashboardTarget you can put in the number and use it on a dashboard. If the goal is changed 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.
An auto-updated example would be something like "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.)
Included in the unmanaged package are three flows to act on DashboardTarget objects:
- 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.
- 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.
- TEMPLATE_DashboardTarget_Run_object_updates - This flow is a template for what you would use to put in place automation to regularly refresh your automatic targets. It's built as an auto-launched flow but is really meant to be saved as a new Schedule Triggered Flow and set to run once per day, for example. I put a pause element of zero days before the flow calls DashboardTargets_Contact_targets so that SOQL Query limits are reset. If you think you will have a lot of dashboardtarget records you can modify this flow to further break up your flow into separate transactions to avoid limits.
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.
If you want to use this project in real life I strongly recommend that you test in a sandbox first!
-
Make sure that you install the UnofficialSF flow component first or you will get an install error.
-
Install the unmanaged package:
- Production/Dev/Scratch Install: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t8W000003BI9K
- Sandbox Install: https://test.salesforce.com/packaging/installPackage.apexp?p0=04t8W000003BI9K If you select Install for Admins only then only the system administrator profile will have visibility for the DashboardTargets tab and create/read/edit permissions on the object. There are two permission sets included for giving visibility for non-admin users. Or you can choose Install for All Users and edit permissions will be given to other profiles. (Including Delete permissions, which you might want to manage...)
-
The Before-Save flow that keeps SOQL Query updated based on SOQL WHERE Clause installs in a ready-to-use state. You just need to activate it.
-
The other flows install as flow templates. Do not activate those. You should Save As to create a new flow before activating your version. (I don't recommend activating the original flow because any later installation of a version of this package will revert the flow to the packaged flow. So any changes you made will be lost.)
-
Go create your first dashboard with dynamically-set gauges!
-
The packaged template DashboardTargets_Contact_targets only updates dashboardtargets that are about contact records. You will want to make versions of this flow for any other objects you or your users are going to have auto-updated dashboardtargets about. (Don't forget to add to the DashboardTargets_Contact_targets whenever you make a flow for updating dashboardtargets about a new object!)
-
As noted above, I expect that the packaged template flow to update all dashboardtargets (DashboardTarget_Run_object_updates) will be saved as a Schedule Triggered Flow that runs at least once per day to keep auto-updated dashboardtargets up-to-date. But you also might want to keep an auto-launched version of this flow and then put a button on the DashboardTarget page layout to update all targets right away. This will allow users to build new auto-update dashboardtargets without having to wait until the next day for them to have a value in Target.
- You could create a New Action on DashboardTarget that launches this flow, then add that to the page layout.
- Or you could install the free Launch Flow in Modal from SalesforceLabs and put it on the DashboardTarget Lightning Page for users to click.
- You may want to edit the page layout and/or override the predefined actions on that layout to hide the Change Owner button (if not relevant for your usage) or the Clone button (if you don't want users to be able to clone existing DashboardTarget records.)
The idea for developing this project was sparked by my work with the Academy Group.
If you found this tool useful I would love it if you showed your support through a donation to Enchantment Theatre Company, which inspires children to dream, explore, think, and connect through imaginative storytelling onstage and in the classroom. I am the chairman of the board of ETC.