There are 2 Custom objects Position__c and Job_postings__c. They both have master detail relationship. where Position__c is master and job posting is detail.
Requirement: For a day only one Job posting should be created by the user for a particular Position. On the same day when the user is trying to create another Job posting for the same Position, error message should be thrown. But on the next day the user should be able to create a new Job posting for that same Position.
How can this be achieved using triggers?. Also i want to know whether this can be achieved with workflows and validation rule?.
Best Answer
You will have a trigger on the job posting object. When inserted (before insert), you should check if the position for that job posting already has other job postings. If yes, then you should get the time of the last one inserted. If the date equals today, then you cannot insert the object (using
.addError
method).It would probably look like this: