+ Start a Discussion
HNT_NeoHNT_Neo 

Validation Rule for Multiple Record Types

Trying to write a validation rule where: 

Picklist value Status of Completed is chosen on RecordTypeID 012d0000001lA4R or 012d0000002MB5S or 012d0000003NC6D or 012d0000004OD7E, the AcitivityDate must not be NULL. 

Here is my attempt, but have not succeded: 
 
AND
(ISPICKVAL(Status,"Completed"),
 AND(RecordTypeId,"012d0000001lA4R","012d000003NC6D","0120000002MB5S"),
ISBLANK(ActivityDate)
)



 
Best Answer chosen by HNT_Neo
VamsiVamsi
AND
(ISPICKVAL(Status,"Completed"),
 OR(RecordTypeId= "012d0000001lA4R",RecordTypeId="012d000003NC6D",RecordTypeId="0120000002MB5S"),
ISBLANK(ActivityDate))
Please try the above and let me know.

Please mark as best answer, If the above helps ...!!!
 

All Answers

VamsiVamsi
AND
(ISPICKVAL(Status,"Completed"),
 OR(RecordTypeId= "012d0000001lA4R",RecordTypeId="012d000003NC6D",RecordTypeId="0120000002MB5S"),
ISBLANK(ActivityDate))
Please try the above and let me know.

Please mark as best answer, If the above helps ...!!!
 
This was selected as the best answer
HNT_NeoHNT_Neo
thank you!
Amit Chaudhary 8Amit Chaudhary 8
Hi JH_Neo,

I will suggest you try to avoid to use recordType Id in validation rule. As once you will deploy change in production that will fail As ID will not same in sandbox and production
Please try to update your validation like below
AND(
	ISPICKVAL(Status,"Completed"),
	OR(
		$RecordType.Name= "Name A",
		$RecordType.Name="Name B",
		$RecordType.Name="Name C"
	),
	ISBLANK(ActivityDate)
)

NOTE:- Always try to avoid hardcording

 
Guillaume Loubier CGIGuillaume Loubier CGI
Actually, you better use DeveloperName over Name. If you're using multiple languages, the Name is what the user sees, it will may get translated.
It is best practice to always use DeveloperName since it is less likely to up changed.

Therefore, the code would look like
AND(
	ISPICKVAL(Status, "Completed"),
	OR(
		RecordType.DeveloperName= "Name A",
		RecordType.DeveloperName= "Name B",
		RecordType.DeveloperName= "Name C"
	),
	ISBLANK(ActivityDate)
)