0

Please can anyone suggest me on how an admin can be notified by email if account owner owns more than 100 records. I've created a report to get the record count for each account owner. Then in order to be notified, I've used subscription. This notified me with the total record count of all account owners which is not useful. Please let me know if there is any alternate way for this requirement.

  • To what end do you wish to be notified? Should you be notified as soon as an owner gains +100 accounts? Should the owners be aggregated into a daily email? If using summaries - once you are made aware of the particular owner, should they continue to show up in the email in future sends? – user43881 Jan 18 '18 at 22:48
  • I should receive an email as soon as account owner gains 100 records. – user99 Jan 19 '18 at 8:46
1

"No code" solution: You could use the Declarative Lookup Rollup Summaries package. Create an integer field on the User object, and set up a real-time rollup that counts child Accounts via the OwnerId lookup.

Then you can put a Workflow Rule or Process Builder on the User object that fires whenever the count field is edited to become at least 100, and have it do something like send an e-mail or make a Chatter post or such.

0

Here's some pseudocode you may be able to use:

trigger (after insert, after update)

Map<Id, Integer> ownercount = new Map<Id, Integer>();

for(AggregateResult ar : [select count(Id) reccount, ownerId, from Account group by ownerId ]){
ownercount.put((Id)ar.ownerId, (Integer)ar.reccount);
}

List<EmailMessage> messagestosend = new List<EmailMessage>();

for(Account a : trigger.new){
if(ownercount.get(a.ownerId) > 100){
 ... create email and add to list
}

send messagestosend

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.