You need to sign in to do that
Don't have an account?
Sainath Venkat
trigger to check check box on account
Hello guys
I am having one scenario, while creating contact, I will be checking the email id of contact and if duplicate email id found for specific record then I have a Checkbox__c field on account and it should be unchecked.
by default Vheckbox__c will be checked.
While creating contact for a particular account,if email is already found on that particular account then checkbox should be unchecked
I am having one scenario, while creating contact, I will be checking the email id of contact and if duplicate email id found for specific record then I have a Checkbox__c field on account and it should be unchecked.
by default Vheckbox__c will be checked.
While creating contact for a particular account,if email is already found on that particular account then checkbox should be unchecked
You can refer the following trigger helper for your requirement.
Let me know if u face any issue for this trigger helper.
Thanks for the quick update, can you please help me how to call this handler into trigger if possible.
the handler works perfectly but it's not working on updation, means lets say I have two contacts with unique email id's then Checkbox__c on account will be checked and lets say if I edit one of the contact and give email id as same as other contact then Checkbox__c should get unchecked but its not working.
on update its not working.can you help me for the same please if possible
Try this code.
trigger Check_Account on Contact (before insert,before update) {
list<contact> conlist=new list<contact>();
conlist=[select id,email,accountid from contact where email!=null];
set<id> Accid=new set<id>();
for(contact con:conlist){
for(contact c:trigger.new){
if(con.AccountId==c.Accountid){
if(con.email==c.email){
Accid.add(c.Accountid);
}
}
}
}
list<Account> acclist=new list<Account>();
acclist=[select id,checked__c from account where id in:Accid];
for(Account a:acclist){
a.checked__c=false;
}
update acclist;
}
Hope It will help you.
Thanks
Ajay Dubedi