1

How to display no of (count) unique accounts from the campaign member related list on the campaign detail page. [P.S: If two campaign members belongs to the same account it should count the no of accounts as 1, unique no of accounts is what we are looking for]

2
  • Where this count needs to be stored? Campaign? On update of campaign(trigger) or on specific time(batch) Commented Apr 29, 2016 at 12:08
  • The idea is to use this field in reports, hence we require this on campaign detail page
    – Ajit
    Commented Apr 29, 2016 at 12:15

1 Answer 1

0

There is no configuration through which this can be achieved easily. This can be done via a trigger.

  1. Create a trigger on CampaignMember for after insert, after update, after delete and after undelete.
  2. Get the unique campaign Ids from Campaign Members
  3. Create a aggregate query and group by Campaign Id and Account Id.

The aggregate query should be able to give you the unique count which you can update on Account. You might also require triggers on Contact and Account for handling situations such as Account update on Contact, Contact deletion, Account deletion.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .