You need to sign in to do that
Don't have an account?
Prachi Potdar
ApexTrigger
- Client wants only upto 10 records to be created on the Account object daily. Write code which will run every 15 minutes. It will check for Account object records created in last 24 hour period (12 am to 12 pm). If the count exceeds 10, delete the additional records. Counter will reset at 12 am to 0. Please Any Solution.TIA.
You can try the scheduled batch apex approach mentioned inhttps://salesforce.stackexchange.com/questions/156217/how-to-write-a-batch-class-for-scheduled-deletion/156307 (You will need to customize as per your requirement)
If this information helps, please mark the answer as best. Thank you
Try Below Code Please Mark it As Best Answer If It Helps
Thank You!
Greetings!
In this question, you can use schedule class which will check for Account object records created in the last 24 hour period (12 am to 12 pm) every 15 minutes,
inside the scheduled class, you can write the function which check about number of accounts created in last 24 hour and if the number of records greater than 10 simply
call a trigger function that will delete the account record above 10.
To know more about the scheduler class in salesforce you can refer to the below link.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
---------------------------------------------------------------------------
If this helped you, please mark it as the best answer.
Thank you!
Regards,
Suraj Tripathi