+ Start a Discussion
Karthik keyanKarthik keyan 

No record created on child object when a record created on the parent object


  I have created another trigger on the same kind of coding on others 2 objects,the trigger coding seems to fine but seems not creating child records when insert or update event changes on parent record.Why manipulation was not happening i dont know .Please send your suggestion on this trigger too.

trigger CreateInterviewoofPositionUpdate on Warehouse_14__Position__c  (after insert,after update){
    
    List<Warehouse_14__Interviews__c> interview =new List<Warehouse_14__Interviews__c>();
    //Warehouse_14__Interviews__c inte = new Warehouse_14__Interviews__c();

    if(Trigger.isInsert)
    {
        for(Warehouse_14__Position__c posi:[ select id,Name,Warehouse_14__Type__c ,Warehouse_14__Functional_Area__c,  (select id, Warehouse_14__Rounds__c,Warehouse_14__Status__c,Warehouse_14__Types__c,Warehouse_14__Name__c 
                                          from Warehouse_14__Interviews__r ) from Warehouse_14__Position__c where id IN : trigger.new]){
        for(Warehouse_14__Interviews__c inte:posi.Warehouse_14__Interviews__r)  {      
            if(posi.Warehouse_14__Type__c == 'High Level' || posi.Warehouse_14__Functional_Area__c =='Project Management' || posi.Warehouse_14__Functional_Area__c == 'Infrastructure Architect' 
           || posi.Warehouse_14__Functional_Area__c == 'Domain Expert'){
             
             inte.Warehouse_14__Rounds__c ='Managerial';
             inte.Warehouse_14__Status__c ='N/A';
             inte.Warehouse_14__Types__c ='Telephonic';
             inte.Warehouse_14__Name__c = posi.Id;             
           } else if(posi.Warehouse_14__Type__c == 'Low Level' || posi.Warehouse_14__Functional_Area__c =='Developer' || posi.Warehouse_14__Functional_Area__c == 'DB Admin' 
           || posi.Warehouse_14__Functional_Area__c == 'Telecom Division'){
             
             inte.Warehouse_14__Rounds__c ='Technical';
             inte.Warehouse_14__Status__c ='N/A';
             inte.Warehouse_14__Types__c ='Skype';
             inte.Warehouse_14__Name__c = posi.Id;             
           }   else if(posi.Warehouse_14__Type__c == 'Middle Level' || posi.Warehouse_14__Functional_Area__c =='Banking' || posi.Warehouse_14__Functional_Area__c == 'Insurance' 
           || posi.Warehouse_14__Functional_Area__c == 'Product Inside Sales'){
             
             inte.Warehouse_14__Rounds__c ='Human Resources';
             inte.Warehouse_14__Status__c ='N/A';
             inte.Warehouse_14__Types__c ='Face To Face';
             inte.Warehouse_14__Name__c = posi.Id;             
           }   
             interview.add(inte);
        }
 }                                                                                                             
    insert interview;
    } else {
        for(Warehouse_14__Position__c posi:[ select id,Name,Warehouse_14__Type__c ,Warehouse_14__Functional_Area__c,  (select id, Warehouse_14__Rounds__c,Warehouse_14__Status__c,Warehouse_14__Types__c,Warehouse_14__Name__c 
                                            from Warehouse_14__Interviews__r ) from Warehouse_14__Position__c where id IN : trigger.new]){
        for(Warehouse_14__Interviews__c inte:posi.Warehouse_14__Interviews__r)  { 
        if(posi.Warehouse_14__Type__c == 'High Level' || posi.Warehouse_14__Functional_Area__c =='Project Management' || posi.Warehouse_14__Functional_Area__c == 'Infrastructure Architect' 
           || posi.Warehouse_14__Functional_Area__c == 'Domain Expert'){
             
             inte.Warehouse_14__Rounds__c ='Managerial';
             inte.Warehouse_14__Status__c ='N/A';
             inte.Warehouse_14__Types__c ='Telephonic';
             inte.Warehouse_14__Name__c = posi.Id;             
           } 
         else if(posi.Warehouse_14__Type__c == 'Low Level' || posi.Warehouse_14__Functional_Area__c =='Developer' || posi.Warehouse_14__Functional_Area__c == 'DB Admin' 
           || posi.Warehouse_14__Functional_Area__c == 'Telecom Division'){
             
             inte.Warehouse_14__Rounds__c ='Technical';
             inte.Warehouse_14__Status__c ='N/A';
             inte.Warehouse_14__Types__c ='Skype';
             inte.Warehouse_14__Name__c = posi.Id;             
           }   
          else if(posi.Warehouse_14__Type__c == 'Middle Level' || posi.Warehouse_14__Functional_Area__c =='Banking' || posi.Warehouse_14__Functional_Area__c == 'Insurance' 
           || posi.Warehouse_14__Functional_Area__c == 'Product Inside Sales'){
             
             inte.Warehouse_14__Rounds__c ='Human Resources';
             inte.Warehouse_14__Status__c ='N/A';
             inte.Warehouse_14__Types__c ='Face To Face';
             inte.Warehouse_14__Name__c = posi.Id;             
           }    
       
             interview.add(inte);
        }
      }                                          
    update interview;
    }
}

Thanks and Regards,
Karthikeyan
Andy BoettcherAndy Boettcher
Your best bet is to start adding in some System.Debug messages throughout your code and start debugging.  You probably have some logic error or something in here.