You need to sign in to do that
Don't have an account?
jayesh pagare
Trigger to get child record count based createddate for current months/previous months?
I have related contacts and on account i want to get record count of contacts created this month and record count of contacts created on last month
You have to figure out how to do it for the previous month! Try to get the previous month (number) and use the same logic as above - Simple way is to subtract 1 from currentMonth and follow the same logic - but this may not work for January :)
(Reason: An account can have multiple contacts and contacts are usually created after account creation, so in standard scenarios contact count would be zero on Account creation and hence a Trigger on Account won't serve the purpose)
Paste the following code there (change filed name of number fileds on Account object in code)
Let me know how it works
Hit LIKE it it helps you. Mark it as Best Answer if it solves your problem.