You need to sign in to do that
Don't have an account?
chiran jeevi
i want test class for below Recursive trigger
trigger constatus on Contact (After update) {
List<Id> conid=new list<Id>();
if(checkRecursive.runOnce()){
for(contact c:trigger.new){
if(c.Status__c=='inactive')
{
conid.add(c.accountid);
}
}
list<account> acc1=[select id,status__c,(select id,status__c from contacts)from account where ID IN:conid];
list<contact> con =new list<contact>();
for(account a:acc1 )
{
for(contact cc:a.contacts) {
cc.status__c='inactive';
con.add(cc);
}
a.status__c='inactive';
update a;
}
update con;
}
}
List<Id> conid=new list<Id>();
if(checkRecursive.runOnce()){
for(contact c:trigger.new){
if(c.Status__c=='inactive')
{
conid.add(c.accountid);
}
}
list<account> acc1=[select id,status__c,(select id,status__c from contacts)from account where ID IN:conid];
list<contact> con =new list<contact>();
for(account a:acc1 )
{
for(contact cc:a.contacts) {
cc.status__c='inactive';
con.add(cc);
}
a.status__c='inactive';
update a;
}
update con;
}
}
Kindly share the purpose of the trigger I mean what you want to achieve with this trigger. As I checked the trigger logic seems not correct, you are updating account and contact object within same trigger.