• mansi
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies

Hello, 

I have to implement a delete functionality in my trigger. 

trigger is on the child object of the account.

in this trigger when any record on the child object is created then it gets updated on the main Parent account  object. now is there any way by which when the same record gets deleted from the child object  it should be deleted from the parent account also

Please find my trigger below

trigger ABC on ChildObject (after insert,after delete) {
    
Set<Id> accId = new Set<Id>();
//Map<Id,Account> IdValues = new Map<Id,Account>();

if(trigger.isinsert)
{

for(ChildObject  CO : trigger.new)
    {
      accId.add(CO.ChildObject ID);
    }
    
    Map<Id,Account> IdValues = new Map<Id,Account>([select id, Industry__c from Account where id in:accId]);
    if(trigger.isinsert){
    for(ChildObject  CO : trigger.new)
    {
   
      string strInt=IdValues.get(CO.ChildObject ID).Industry__c;
      IdValues.get(CO.ChildObject ID).Industry__c=(strInt==null?'':strInt) +';'+ CO.Industry__c;
      
    }
    
    update IdValues.values();
}
}/*

if(trigger.isdelete){
 
 for(ChildObject  CO : trigger.old)
   {
   
   <delete functionality >
      
   
   }
   }
}

  • December 06, 2011
  • Like
  • 0

Hi can any one tell me how to cover the below code in the test class..

Class name is SaveOnEditAmexCampaignCtrlrExt 

only first few lines of my below code are covered.. please tellme  how to cover the whole method

 

       }

  • November 28, 2011
  • Like
  • 0

Hi can any one tell me how to cover the below code in the test class..

Class name is SaveOnEditAmexCampaignCtrlrExt 

only first few lines of my below code are covered.. please tellme  how to cover the whole method

 

  • November 28, 2011
  • Like
  • 0

hello, Can any one please tell me how to write a test class for the below class.. please help me out.

 

public class offerGenerationController{
    Amex_offer__c amexoffer;
    String selectedRadioOption;
    public Attachment newfile{get;set;}
    
    public void setAmexoffer(Amex_Offer__c amexoffer){
        this.amexoffer = amexoffer;
        system.debug('In the setter **** :'+amexoffer);
    }
    
    public offerGenerationController(ApexPages.StandardController stdController){
    }
    public Amex_Offer__c getAmexoffer(){
        if(amexoffer == null) amexoffer = new Amex_Offer__c();
        system.debug('In the getter **** :'+amexoffer);
        return amexoffer;
    }
    
    public void setSelectedRadioOption(String selectedRadioOption){
        this.selectedRadioOption = selectedRadioOption;
    }
    
    public String getSelectedRadioOption(){
        return selectedRadioOption;
    }
        
    public void uploadFiles(){
        newfile = new Attachment();
        newfile.ParentId = amexoffer.id;
        if(newFile.Body!=null){
            newfile.Name = String.ValueOf(Date.today()) + ' - Customer upload'; 
            insert newfile;            
        }
    }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Spend1','Spend'));
        options.add(new SelectOption('Spend2','Spend'));
        options.add(new SelectOption('Spend3','Spend')); 
        options.add(new SelectOption('Spend4','Spend'));
        options.add(new SelectOption('Spend5','Spend'));
        return options;
    }
            
}

  • November 23, 2011
  • Like
  • 0

Hi can any one tell me how to cover the below code in the test class..

Class name is SaveOnEditAmexCampaignCtrlrExt 

only first few lines of my below code are covered.. please tellme  how to cover the whole method

 

       }

  • November 28, 2011
  • Like
  • 0

Hi can any one tell me how to cover the below code in the test class..

Class name is SaveOnEditAmexCampaignCtrlrExt 

only first few lines of my below code are covered.. please tellme  how to cover the whole method

 

  • November 28, 2011
  • Like
  • 0

hello, Can any one please tell me how to write a test class for the below class.. please help me out.

 

public class offerGenerationController{
    Amex_offer__c amexoffer;
    String selectedRadioOption;
    public Attachment newfile{get;set;}
    
    public void setAmexoffer(Amex_Offer__c amexoffer){
        this.amexoffer = amexoffer;
        system.debug('In the setter **** :'+amexoffer);
    }
    
    public offerGenerationController(ApexPages.StandardController stdController){
    }
    public Amex_Offer__c getAmexoffer(){
        if(amexoffer == null) amexoffer = new Amex_Offer__c();
        system.debug('In the getter **** :'+amexoffer);
        return amexoffer;
    }
    
    public void setSelectedRadioOption(String selectedRadioOption){
        this.selectedRadioOption = selectedRadioOption;
    }
    
    public String getSelectedRadioOption(){
        return selectedRadioOption;
    }
        
    public void uploadFiles(){
        newfile = new Attachment();
        newfile.ParentId = amexoffer.id;
        if(newFile.Body!=null){
            newfile.Name = String.ValueOf(Date.today()) + ' - Customer upload'; 
            insert newfile;            
        }
    }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Spend1','Spend'));
        options.add(new SelectOption('Spend2','Spend'));
        options.add(new SelectOption('Spend3','Spend')); 
        options.add(new SelectOption('Spend4','Spend'));
        options.add(new SelectOption('Spend5','Spend'));
        return options;
    }
            
}

  • November 23, 2011
  • Like
  • 0