function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PARAG BHOR 19PARAG BHOR 19 

Want to prevent Deletion or Creation of Accounts in the month of January

Want to prevent Deletion or Creation of Accounts in the month of January. How can we achieve this, pls help me gys. I am new to apex.
I tried some solutions but created date is null in before Insert and addError is not allowed in after trigger. So how can we bring them both together to display an error whenever an account is going to be created
ShirishaShirisha (Salesforce Developers) 
Hi Parag,

Greetings!

You can achieve this by using the validation rule and please refer the sample expression as below;
 
Expression: MONTH(DATEVALUE(CreatedDate)) = 1

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri