You need to sign in to do that
Don't have an account?
Daniel Hermann 10
Trigger to create a custom object record when a new opportunity is made.
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);
}
}
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);
}
}
I would imagine something like this would work, based on standard naming:
FYI - you know you could totally do this with Process builder too right? Then you don't need code/tests/release headaches...?!!
All Answers
I would imagine something like this would work, based on standard naming:
FYI - you know you could totally do this with Process builder too right? Then you don't need code/tests/release headaches...?!!