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
carmilyn.c martincarmilyn.c martin 

Trigger on current year and next year


I would like to avoid our users from creating PTO records with pto_date__c of January 10 onwards (of next year). PTO Records of current year is only counted if pto_date__c is within January 11 (current Year) until January 10 of next year.

I would also like to avoid them deleting these PTO records. They cannot delete their PTO records with pto_date__c from January 11 (last Year) to january 10 of this year. 

I am not sure how to do this. 
Tanuja JTanuja J
Have you gone through this link?
This gives you an idea to write an approval process for the PTO.
And for preventing from deleting and creating new PTO you must 
1.Create a custom field (checkbox) on the PTO object.
2. when the conditions are met then update the checkbox by checking it.
3.Now using the checkbox field as condition write a trigger for preventing user from deletion and also creating new PTO.

carmilyn.c martincarmilyn.c martin
How can  this be possible using trigger. I need an idea how to write a script where date greater than "Jan 11 of next year"

Thank you. 
carmilyn.c martincarmilyn.c martin
I need to create a trigger where (tot.Date_vod__c < (THIS_YEAR( --- THIS YEAR, JAN 11. I am not sure if I am doing it correctly.