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
MDBMDB 

Validation rule to stop duplicate record types from being created

I have a custom object (visit) that is child record of another object(patient). The relationship is one to many, one patient can have many visits. Visit object has multiple record types.
I would like to prohibit duplicate visit types for any one patient. So each patient could have a preop, 1 month and 3 month visit. But I would like to stop a patient from having 2 preop visit types.
 
So the rule would look to see if there are any visit records pre-existing that already contain the master-detail value (this would reference the parent object) and new record type. I think that is the simplest way, but tell me if I am off base
 
thanks for any help
 
 
Venkat PolisettVenkat Polisett

MDB wrote:

I have a custom object (visit) that is child record of another object(patient). The relationship is one to many, one patient can have many visits. Visit object has multiple record types.
I would like to prohibit duplicate visit types for any one patient. So each patient could have a preop, 1 month and 3 month visit. But I would like to stop a patient from having 2 preop visit types.
 
So the rule would look to see if there are any visit records pre-existing that already contain the master-detail value (this would reference the parent object) and new record type. I think that is the simplest way, but tell me if I am off base
 
thanks for any help
 
 

You cannot do this with a formula on visit object as there is no way to get existing record count of grouped by recordtype. You will need to write a trigger to achieve that.