Salesforce Fact #905 | Unique Leadsource from related contacts

In this blog post, I have created a screen flow to find out the unique Leadsource of related contacts for an account record.

Here are the steps:

1) First we are getting the related contact records where the LeadSource is not blank for that account. Also, we are ordering the result ascending by leadsource for later processing.

2) Then we are checking if any data is found. If data is not found, showing an error screen.

3) If data is found, we are running a loop on the fetched records and checking if the previous value and current value is the same. This check is to make sure we are getting unique values and skipping the duplicate values.

4) At the end, we are showing the data in the datatable.

Note: If the number of related contacts are huge, then we need to revisit this solution to avoid hitting any limits.

Attached are the screenshots.












Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow