You need to sign in to do that
Don't have an account?
3C
Trigger to insert custom obj record based on opportunity
I have the following trigger, but it's not working as intended. There are no errors in the code.. any ideas?
trigger createCancellationReport on Opportunity (after update) { List<Win_Loss_Report__c> reportstoinsert = new List<Win_Loss_Report__c>(); for (Opportunity opp : Trigger.new) { // Create cancellation report only for cancellation oppys if (opp.StageName == 'Closed Won' & opp.Cancellation_Reason__c != null) { Win_Loss_Report__c cr = new Win_Loss_Report__c(); cr.Opportunity__c = opp.id; cr.Name = 'Cancellation Report'; cr.RecordTypeID = '012J00000009NC9'; reportstoinsert.add(cr); // bulk process } } }
Here is modified code :
trigger createCancellationReport on Opportunity(after update) {
List < Win_Loss_Report__c > reportstoinsert = new List < Win_Loss_Report__c > ();
for (Opportunity opp: Trigger.new) {
// Create cancellation report only for cancellation oppys
if (opp.StageName == 'Closed Won' & opp.Cancellation_Reason__c != null) {
Win_Loss_Report__c cr = new Win_Loss_Report__c();
cr.Opportunity__c = opp.id;
cr.Name = 'Cancellation Report';
cr.RecordTypeID = '012J00000009NC9';
reportstoinsert.add(cr); // bulk process
}
}
if(reportstoinsert.size() > 0){
insert reportstoinsert;
}
}
:::======================================================================:::
Qusetion Solved ? then mark as best answer to make helpful to others .....
All Answers
Here is modified code :
trigger createCancellationReport on Opportunity(after update) {
List < Win_Loss_Report__c > reportstoinsert = new List < Win_Loss_Report__c > ();
for (Opportunity opp: Trigger.new) {
// Create cancellation report only for cancellation oppys
if (opp.StageName == 'Closed Won' & opp.Cancellation_Reason__c != null) {
Win_Loss_Report__c cr = new Win_Loss_Report__c();
cr.Opportunity__c = opp.id;
cr.Name = 'Cancellation Report';
cr.RecordTypeID = '012J00000009NC9';
reportstoinsert.add(cr); // bulk process
}
}
if(reportstoinsert.size() > 0){
insert reportstoinsert;
}
}
:::======================================================================:::
Qusetion Solved ? then mark as best answer to make helpful to others .....