// in contact obj there is a field IsChecked__c // this check box should be checked for any one record not more than // this check box should be checked for atleast one record you can not uncheck for all record
public class checkBox_helper { public static void PrimaryCheckbox(list<contact> triggerNew){ list<contact> conList=[select id,IsChecked__c from contact where IsChecked__c=true]; boolean checkedTrue=false; for(contact con:triggerNew){ if(con.IsChecked__c==true && conList.size()>0){ checkedTrue=true; } } if(checkedTrue==true){ for(contact co:conList){ co.ischecked__C=false; } update conList; } } }
// this check box should be checked for any one record not more than
// this check box should be checked for atleast one record you can not uncheck for all record
public class checkBox_helper {
public static void PrimaryCheckbox(list<contact> triggerNew){
list<contact> conList=[select id,IsChecked__c from contact where IsChecked__c=true];
boolean checkedTrue=false;
for(contact con:triggerNew){
if(con.IsChecked__c==true && conList.size()>0){
checkedTrue=true;
}
}
if(checkedTrue==true){
for(contact co:conList){
co.ischecked__C=false;
}
update conList;
}
}
}
Please describe your requirement clearly
What is your condition to update that field as true?
Thank you!
Regards,
Suraj Tripathi