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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Validation rule help --

Hi, I need to write a valdation rule for below scenario, 
Two Objects -- Eg, Accounts and Contacts. Contacts has a picklist called "Type" (values - 'Business' , 'Professional')..
I have a vf page where i can enter Account details, (multiple)Contacts and save all at one go.. Now the requirement is, if I save more than one contact, Type should be same - means, it should be either Bussiness or Professional for all contacts.. 
Is it possible to achieve this using ONLY vaidation rule (i cant write trigger for some reasons).?
 
Best Answer chosen by Vigneshwaran Loganathan
Abhishek BansalAbhishek Bansal
Hi Vigneshwaran,

Validation rule works record wise and not on the buk records so you can't acheive this with validation rules. You can validate this scenario in the controller class of your VF page. Please let us know if you need any help with the code snippet.

Thanks,
Abhishek Bansal. 

All Answers

Abhishek BansalAbhishek Bansal
Hi Vigneshwaran,

Validation rule works record wise and not on the buk records so you can't acheive this with validation rules. You can validate this scenario in the controller class of your VF page. Please let us know if you need any help with the code snippet.

Thanks,
Abhishek Bansal. 
This was selected as the best answer
Vigneshwaran LoganathanVigneshwaran Loganathan
Hi Abhishek, sorry for the delay.. Yes, this is what I have thought.. will go for trigger then. Thanks.!