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
balakumaran Ramanujambalakumaran Ramanujam 

Hi, I have a requirement : I have account and a custom object (Account Plan) with field Active which is a checkbox . Now i have to write a validation rule to make sure there should be only one active filed checked in for one account.Note:relation master

Hi, I have a requirement :  I have account and a custom object (Account Plan) with field Active which is a checkbox . Now i have to write a validation rule to make sure there should be only one active field checked in for one account.Note:they are in master detail relation
CharuDuttCharuDutt
Hii BalaKumaran
Try Beow Trigger
trigger AccountPlanTrigger on Account_Plan__c (before Update) {
		set<id> ApId = new set<id>();
        for(Account_Plan__c Ap : Trigger.new) { 
           if(Ap.Active__c == true && Acc.Active__c!= Trigger.oldMap.get(Acc.Id).Active__c){
           ApId.add(Acc.Account__c);
        	}
        }
  
    list<Account_Plan__c> Aplist = [Select id,Active__c,Account__c from Account_Plan__c Where Account__c In :ApId AND Active__c = true ];
     for(Account_Plan__c Ap : Trigger.new) { 
          if(Aplist.size()>0){
		  Ap.AddError(Another Record Have Active Checked);
		  }
        }
    
}
Please Mark It As Best Answer If It Helps
Thank You! 
Maharajan CMaharajan C
Hi Bala.

1. Create Rollup summary field on your parent object (Account). that Count the number of childs (Account Plan) based on the criteria 'Active  = TRUE.

2  Add the validation rule in Account object that enforces that the value of above rollup field cannot be greater than than 0.

IF(Rollup_Field > 0 , TRUE, FALSE)

Thanks,
Maharajan.C