0

In Lightning Experience I have created a dashboard that displays a number of Account and Opportunity reports. These reports themselves do not apply any filtering on Territories, but the dashboard does. This works perfectly, just select the appropriate Territory in the dashboard filter and this filter is applied to all reports in the dashboard.

One problem: the dashboard is also supposed to show a Leads report. But Leads and Territories do not play well together. I found a trick to find out the appropriate Territory for a Lead (create a dummy Account with the address of the Lead, await Territory assignment and delete the Account), but this is only half the work: I still need to get the dashboard filter to use this information.

Has anybody ever attempted this and succeeded?

1
+50

I don't believe you'll have any luck doing this. The limitations are two-fold:

  1. Leads are not part of Territory Management as they don't have a master-detail relationship to accounts. See this idea. Your workaround (dummy account), which I assume you may have gotten from this help doc, helps utilize it for assignment, but doesn't change the fact that it's not related in a way that the Dashboard can use.

  2. The dashboard filter functionality is not something you can change through the UI (see edit for how to change it below editing xml) and is controlled by what Salesforce deems as equivalent fields. This usually limits you from making easy connections between fields with the same data type across objects. See this idea which is asking for the ability to set up what fields are equivalent or at least match up custom fields with the same name and data type across objects. This would help you if you stamped the Territory Name on a custom field on Leads and could tell the dashboard to use it. As of right now, you can see what Salesforce deems as equivalent fields by putting all your reports on a dashboard first, and then attempting to create a filter. It'll only display fields that are available.


Edit: You actually can technically do this as the below gets around limitation #2 mentioned above

It requires you editing the Dashboard XML directly which allows you to set a field on the Lead report component to use for the defined filter at the dashboard level. The below assume you have a custom field on your Lead object that is filled with the Territory Name. Not saying this is a good idea, but it is a way to achieve this.

  1. Create your dashboard with Opportunity and Account reports
  2. Create your filters based on Territory Name (so it's available to select)
  3. Add your lead reports
  4. Pull the dashboard into your IDE (sfdx force:source:retrieve -m Dashboard)
  5. Manually create the XML property dashboardFilterColumns for the <dashboardComponent> that houses the Lead report (you can check the others to see how it looks)
  6. Edit the <column> to reference your custom Lead field that represents Territory Name
  7. Deploy the dashboard with your changes

Example XML of the dashboardGridComponent related to your Lead Report where you can inject the reference to the field that the filter should use.

       <dashboardGridComponents>
            <colSpan>4</colSpan>
            <columnIndex>0</columnIndex>
            <dashboardComponent>
                <autoselectColumnsFromReport>false</autoselectColumnsFromReport>
                <componentType>FlexTable</componentType>
                <dashboardFilterColumns>
                    <column>Lead.Territory_Name__c</column>
                </dashboardFilterColumns>
                <flexComponentProperties>
                    ....
                </flexComponentProperties>
                <groupingSortProperties/>
                <header>New Leads Report</header>
                <report>unfiled$public/New_Leads_Report_LDm</report>
            </dashboardComponent>
            <rowIndex>16</rowIndex>
            <rowSpan>8</rowSpan>
        </dashboardGridComponents>
  • Yes, I already had my doubts about it. Maybe some genius will come up with a brilliant solution, but I am not holding my breath. I am withholding the bonus for a few more days, however ;-) – Sander de Jong Jul 22 '20 at 13:12
  • 1
    @Sander de Jong - I did find a way to do it if you're ok with editing the xml. You'll have to have some process/code to assign the territory name to a custom field on Lead though. – Kris Goncalves Jul 22 '20 at 17:40
  • Wow, just wow! You found a way, great. For myself, I found a different way of doing the filtering, namely on AccountManager. It turns out that one of the several available AccountManager filters did exactly what I wanted (not all of them behave in the same way, for some strange reason). So I am using that, as the assignment of a Lead to a Territory is not the most elegant and simple thing to do. In a few fours I can award you the bonus as well. Thanks again! – Sander de Jong Jul 23 '20 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.