Sub topic 8
Building a dynamic dashboard
This chapter assumes you can build a report, create a dashboard with components, and set a running user. It also assumes you know how profiles, roles, and sharing rules decide which records a user can see. If any of these is unfamiliar, review the earlier chapters on the running user and on summary reports first.
By the end you will be able to:
- Turn an existing dashboard into a dynamic dashboard.
- Prepare the source reports so they behave correctly for each viewer.
- Audit dynamic dashboards with SOQL.
- Recognize the common ways a dynamic dashboard goes wrong.
What a dynamic dashboard changes
A standard dashboard has one running user. Every viewer sees the data that person can see, no matter what the viewer's own access is. This is useful for a company-wide view, but it means a sales rep and a sales director see identical numbers.
A dynamic dashboard replaces the fixed running user with the viewer. In Lightning Experience the setting is View dashboard as, and the option is The dashboard viewer. Salesforce runs each report in the dashboard as the person who opens it, so record visibility follows that person's profile, role hierarchy, sharing rules, and permission sets.
One dashboard therefore serves many audiences. Without it you would build a copy per person or per team and maintain each one.
| Setting | Data shown | Typical use |
|---|---|---|
| Run as a specified user | Everything that user can see, for every viewer | Executive or company-wide summary |
| Run as logged-in user (dynamic) | Only what the viewer can see | Personal or team scorecards |
| View as "Me" (the saver) | What the dashboard owner can see | Personal dashboards that are not shared |
How the data flows
Opening a dynamic dashboard triggers a refresh in the viewer's context. The diagram shows two viewers opening the same dashboard.
Dynamic dashboards do not bypass sharing. They apply it per viewer, which is why they suit data that must stay restricted.
Build the source report
The dashboard only shows what its reports return, so prepare the reports first.
- Create a summary report on Opportunities.
- Set the View or scope filter to All opportunities. Do not use My opportunities. The scope is evaluated as the viewer anyway, but All opportunities keeps the intent clear: "everything this viewer can see."
- Add the filter Closed = False.
- Group rows by Stage.
- Summarize Amount with a sum.
- Save the report in a folder that dashboard builders can reach.
The same grouped totals can be written as SOQL, which is a good way to check what the report should return:
SELECT StageName, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
GROUP BY StageNameSOQL executed in the Developer Console respects the sharing of the user who runs it, in the same way the report does for each viewer. Running it as different users shows you the variation the dashboard will produce.
Pick filters that depend on the viewer
Dynamic dashboards work best when reports use viewer-relative scopes. These help:
- Scopes such as My opportunities, My team's opportunities, or My cases. In a dynamic dashboard, "my" means the viewer.
- Role hierarchy visibility. A manager sees subordinates' records, and a rep sees only their own.
- Filters on fields such as Owner, where the visible rows already vary by user.
A report with hard-coded filters, such as Owner = Dana Smith, shows Dana's data to everyone who has access to it. A dynamic running user does not change that.
Create the dynamic dashboard
- Open Dashboards, and select New Dashboard.
- Give it a name, an API-friendly description, and a folder. The folder must be shared with the people who need to view it.
- In the editor, add a chart component from the pipeline report. Add a metric or table if you want a total or a list.
- Select the properties gear, then View dashboard as, then The dashboard viewer.
- Save the dashboard.
The option is not available to everyone. Your user needs the Manage Dynamic Dashboards permission, which an administrator grants through a profile or permission set. Without it, you can see the other running-user choices but not the viewer option.
Letting managers look at their team
Some orgs allow authorized users to view a dynamic dashboard as someone else. The setting is Let authorized viewers choose whom to view the dashboard as. People with the View My Team's Dashboards permission can then pick a user below them in the role hierarchy. This gives a manager a way to see what a rep sees, without cloning the dashboard.
Check the options on the dashboard properties page after saving, because the available choices depend on edition and permissions.
Audit dynamic dashboards with SOQL
Dashboards are records you can query. The Dashboard object has a Type field that records the running-user choice. This query lists the dynamic dashboards in an org:
SELECT Id, Title, DeveloperName, FolderName, Type, RunningUserId
FROM Dashboard
WHERE Type = 'LoggedInUser'The Type values you will meet are SpecifiedUser (a fixed running user), LoggedInUser (dynamic), and MyTeamUser (the viewer's team). This query counts dashboards by type:
SELECT Type, COUNT(Id) total
FROM Dashboard
GROUP BY TypeUse the second query before you convert more dashboards. Editions cap the number of dynamic dashboards. The cap varies by edition, so check the current figure in Salesforce Help for your edition. When the cap is reached, you cannot save another dashboard as dynamic until you remove or convert one.
The same property appears in the Metadata API as the dashboard's dashboardType. This matters if you deploy dashboards between sandboxes and production. A dashboard that arrives with a different type than you expected usually means a deployment overwrote it.
Refresh behavior
Static dashboards can refresh on a schedule. Dynamic dashboards cannot, because there is no single set of numbers to prepare ahead of time. The data depends on who opens the dashboard.
- The dashboard refreshes when a viewer uses the Refresh button.
- A viewer sees the data as of the last refresh in their own context, so two viewers can see different timestamps.
- If you need a scheduled email with a fixed set of numbers, use a static dashboard with a chosen running user instead.
The next chapters on refresh and subscriptions cover the scheduling details. For now, remember that choosing dynamic means giving up scheduled refresh.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| "View dashboard as" lacks the viewer option | You lack Manage Dynamic Dashboards | Ask an administrator for the permission |
| Save fails when switching to dynamic | The edition's dynamic dashboard limit is reached | Query counts by `Type`, then convert or delete unused dynamic dashboards |
| Every viewer sees the same numbers | The report filters on a fixed user, or the org-wide default makes records public | Use viewer-relative scopes, and check sharing settings |
| A component is empty for one viewer | That viewer has no access to matching records | Compare the viewer's role and sharing with the report's filters |
| A viewer cannot open the dashboard | The viewer lacks access to the dashboard folder | Share the folder with the right access level |
| A component shows an access error | The report's folder or its fields are not available to that viewer | Review the report folder and field-level security |
A frequent mistake is to treat an empty component as a bug. In a dynamic dashboard an empty component is often correct: the viewer genuinely has no matching records.
Design guidance
- Prefer dynamic dashboards for personal scorecards and team views. Prefer static ones for company-wide summaries that must be identical for everyone.
- Because the cap on dynamic dashboards is small, use each one for a broad audience rather than a single team.
- Name dynamic dashboards so viewers know the numbers are personal, for example "My Pipeline."
- Keep the report count low. Each component runs its report once for each viewer who refreshes, which adds load.
Exercise
A sales director opens a dynamic dashboard and sees $2.4M in open pipeline. A rep opens the same dashboard and sees $180K. Is this a defect, and which two things would you check if the director expected the rep to see $2.4M too?
Show answer
It is expected behavior, because each report runs as the person viewing it, and the director's role hierarchy gives access to more records. If the rep should see the larger number, check first whether the dashboard's running user should instead be a specified user (a static dashboard), and second whether the sharing settings or report filters limit the rep's access.
Exercise
Write a SOQL query that shows how many dashboards use each running-user type, and explain why you would run it before converting another dashboard to dynamic.
Show answer
SELECT Type, COUNT(Id) total FROM Dashboard GROUP BY Type. The count of LoggedInUser rows shows how many dynamic dashboards the org already has. Compare it with your edition's limit, because you cannot save another dynamic dashboard once the limit is reached.