I need to create a trigger to prevent duplicate records in the Detail table of a custom Master-Detail type relationship. One field, called Name, must be unique for all records in the Detail record collection for each Master record. Thus, the trigger must prevent duplicate records for 2 fields, the Name field plus the Id of the Master record. In the force.com Cookbook, page 118, there is an example, but it is for a single field and I don't understand how to modify it for 2 fields. Can anyone help?
Firstly, I have created 2 custom objects:
1) Customer Project (Master)
2) Customer Project Team Assignments (Detail)
I need to create a validation rule or workflow rule to restrict a user from selecting a Contact on the Customer Project Team Assignment object that is already associated w/ the same Customer Project object.
The Contact can however be associated w/ different Customer Projects just no duplicates for a single Customer Project.
Does this make sense? Can anyone help? Please ask questions if I've left out some critical information.