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
chiran jeevichiran 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;
    }
}
DeveloperSudDeveloperSud
Hi Chiran Jeevi,

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.