• Nandini
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
Hi Team,

How to write test class for custom exception class ?
public class CustomException extends Exception {
    boolean escape ;
    String errMsg ; 
   public CustomException(String errMsg, boolean escape){
        this.errMsg = errMsg;
        this.escape = escape;
    }
    
    public void addError(String errMsg, boolean escape){
        
    }
    
    
}
Please let me know.

Thanks,
Nandu
 
  • September 27, 2018
  • Like
  • 0
Hi Team,

I have created trigger for Rolllup summary from child to Parent using helper classes.
How can we show the error message to user, if the parent object is not updated from child object.
Please let me know.

Thanks,
Nandu.

 
  • September 25, 2018
  • Like
  • 0
Hi Team,

Rollup summary for lookup.
We need to create only one method for After update and Delete operations or We need to Created seperate methods for both update and delete operations.
Scenario : 1
-----------------
     if(Trigger.isUpdate || Trigger.isDelete){
        if(Trigger.isAfter){
            if(AccountHandlerCls.firstRun){
                AccountHandlerCls.firstRun = false;
                AccountHandlerCls.rollupSum(Trigger.Old);
            }
        }
    }
	
Scenario : 2	
------------------------
	 if(Trigger.isUpdate){
        if(Trigger.isAfter){
            if(AccountHandlerCls.firstRun){
                AccountHandlerCls.firstRun = false;
                AccountHandlerCls.rollupSumUpdate(Trigger.Old);
            }
        }
    }
	 if(Trigger.isDelete){
        if(Trigger.isAfter){
            if(AccountHandlerCls.firstRun){
                AccountHandlerCls.firstRun = false;
                AccountHandlerCls.rollupSumDelete(Trigger.Old);
            }
        }
    }
Please let me know...
Thanks
Nandu.
 
  • September 20, 2018
  • Like
  • 0
Hi Team,

I have a doubt on Database.update .
Database.update(oppToUpdate,false); In this statement what is the use of ' false' , is it mandatory ? ( passing list obj).
Database.update(mapToUpdate.values()); In this statement we need to put ' false' or not necessary. (passing map).

Please let me know.

Thanks,
Nandu.
  • September 20, 2018
  • Like
  • 0
Hi Team,

How can we write the test class for below class.
public with sharing class ControllerCls {
      
    public Contact co{get;set;}
    
    private final Contact con;
    
    private ApexPages.StandardController sc{get;set;}
    
    public Opportunity opp = new Opportunity();
    
    public ControllerCls(ApexPages.StandardController sc){
        this.sc = sc;
        con = (Contact)sc.getRecord();
        
        if(con.Name__c != Null){
            opp =[select id,name,AccountId from Opportunity where id =: con.Name__c limit 1];
        }
            
        co = new Contact();
        
        co.AccountId = opp.AccountId;
      
    }
    
    public PageReference save(){
        try{
            Database.insert(con);
            PageReference pr = new PageReference('/'+con.Id);
       		pr.setRedirect(true);
            return pr;
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));
            return null;
        }        
    }
    
    public PageReference saveNew()
     { 
         PageReference pr; 
         try{
             Database.insert(con);
         Schema.DescribeSObjectResult describeResult = sc.getRecord().getSObjectType().getDescribe();
         pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e');
         pr.setRedirect(true);
         return pr;
         }catch(Exception e){ 
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
         return null; }
     
     }
    
}
Please let me know how can we cover 100% code coverage.

Thanks,
sfdc dev.
 
  • September 18, 2018
  • Like
  • 0
Hi Team,

please let me know how can we track the project or tasks ?


Thanks.
 
  • September 11, 2018
  • Like
  • 0
Hi Team,

For before event (before insert or update) triggers on same object need to use static boolean variable in helper classes. Is it mandatory for recusive triggers ? or Not ?

Thanks,
sfdc team.
  • September 11, 2018
  • Like
  • 0
Hi Team,

Rollup summary for lookup.
We need to create only one method for After update and Delete operations or We need to Created seperate methods for both update and delete operations.
Scenario : 1
-----------------
     if(Trigger.isUpdate || Trigger.isDelete){
        if(Trigger.isAfter){
            if(AccountHandlerCls.firstRun){
                AccountHandlerCls.firstRun = false;
                AccountHandlerCls.rollupSum(Trigger.Old);
            }
        }
    }
	
Scenario : 2	
------------------------
	 if(Trigger.isUpdate){
        if(Trigger.isAfter){
            if(AccountHandlerCls.firstRun){
                AccountHandlerCls.firstRun = false;
                AccountHandlerCls.rollupSumUpdate(Trigger.Old);
            }
        }
    }
	 if(Trigger.isDelete){
        if(Trigger.isAfter){
            if(AccountHandlerCls.firstRun){
                AccountHandlerCls.firstRun = false;
                AccountHandlerCls.rollupSumDelete(Trigger.Old);
            }
        }
    }
Please let me know...
Thanks
Nandu.
 
  • September 20, 2018
  • Like
  • 0