• Daniel Hermann 10
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
When a new opportunity is created I need a trigger that will create a new record in a custom object "Project Requirements." When creating a new Project Requirement record the only required fields are the name of the project requirement(default field) and the opportunity (Master-Detail field). When i create a new opportunity it does not seem to fire this trigger even though it is active. Any insight would be greatly appreciated. I have attempted to pass values to the "Opportunity" field or the "Name" field but that results in either a compilation error or the trigger still does not work.

trigger Project_Requirement on Opportunity (after insert) {
    List <Project_Requirement__c> reqToInsert = new List <Project_Requirement__c>();
    for (Opportunity o : Trigger.new) {
        Project_Requirement__c r = new Project_Requirement__c ();
        reqToInsert.add(r);
    }
    try {
        insert reqToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}
When a new opportunity is created I need a trigger that will create a new record in a custom object "Project Requirements." When creating a new Project Requirement record the only required fields are the name of the project requirement(default field) and the opportunity (Master-Detail field). When i create a new opportunity it does not seem to fire this trigger even though it is active. Any insight would be greatly appreciated. I have attempted to pass values to the "Opportunity" field or the "Name" field but that results in either a compilation error or the trigger still does not work.

trigger Project_Requirement on Opportunity (after insert) {
    List <Project_Requirement__c> reqToInsert = new List <Project_Requirement__c>();
    for (Opportunity o : Trigger.new) {
        Project_Requirement__c r = new Project_Requirement__c ();
        reqToInsert.add(r);
    }
    try {
        insert reqToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}