Posts

Showing posts from May, 2019

LIMIT_EXCEEDED, Maximum per user subscription limit reached (copy)

Problem :  Chatter EntitySubscription Limits ? In my project, we follow certain records via after update triggers, if some conditions match. I am getting this error on follow code that creates an EntitySubscription via trigger Description: Error:Apex trigger FollowXYZ caused an unexpected exception, contact your administrator: FollowXYZ: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: LIMIT_EXCEEDED, Maximum per user subscription limit reached.: []: Solution : Before Inserting the 'EntitySubscription' record, Get the count() subscription-id.  If the subscription-id count() is greater then 500, then delete the older EntitySubscription records first, then proceed with inserting the new EntitySubscription records. Code Snippet : 1) Count(userID) SELECT count()  FROM EntitySubscription   WHERE SubscriberId = '00530000005nnYnAAI'    AND ParentId IN...