• MauricioArdila
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

Creating custom exception classes doesn't seem to be documented (well, anyway), and there's some odd behavior when attempting to do so. I'm currently focusing on constructors. Given the following class:

 

 

public class MyException extends Exception{

	private final String exceptionCode;
	
	public MyException(String code) {
		exceptionCode = code;
		// initialization code
	}
}

 

 

The Apex compiler complains with: Save error: System exception constructor already defined: <Constructor>()

 

This class defines a default constructor for the typical reasons: atomic/guaranteed construction, initialization of final variables, etc. Removing the constructor makes the compiler happy. So, are constructors not allowed for classes that extend Exception, or is there some other problem here? 

 

Jeremy

This trigger works just fine in my sandbox, but doesn't pass the test so I can upload into production. Can anyone please help?

 

trigger UpdateCustomeObject_Trigger on Lead (before update) {
//This trigger will associate a Custom Object record with the contact and opportunity associated to the 
//lead after it has been converted.
//The Custom Object is associated to an opportunity only if an opportunity record exist on the Lead.
    for (Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){
            Set<Id> leadIds = new Set<Id>();
            for (Lead lead : Trigger.new) 
                leadIds.add(lead.Id);
            
            Map<Id, CustomObject__c> entries = new Map<Id, CustomObject__c>([select Contact__c, Opportunity__c, Account__c, Lead__c from CustomObject__c where lead__c in :leadIds]);        
            if(!Trigger.new.isEmpty()) {
                for (Lead lead : Trigger.new)  {
                    for (CustomObject__c CustomObject : entries.values()) {
                        if (CustomObject.Lead__c == lead.Id) {
                            CustomObject.contact__c = lead.ConvertedContactId;
                            CustomObject.opportunity__c = lead.ConvertedOpportunityId;
                            CustomObject.account__c = lead.ConvertedAccountId;
                            update CustomObject;
                            
                        }
                    }
                }
            }
        }
    }

}

In my project, i have relationship of pre-project with Opportunity object. Pre-project is a custom object. My functionality is,i want to create Pre-project only through the Opportunity object. it should not be create by Pre-project tab directly.

 

When someone will click on Pre-project New button directly it will show a error message and when someone will

go through the opportunity, he can do easily.

 

Please help me to solve this problem.

 

Thanks in advance!