You need to sign in to do that
Don't have an account?
RossGilbert
Test Coverage for After Insert Trigger
Hi-
Does anyone know how to write the test class for the following trigger? Any code is much appreciated. This is a simple trigger that spontaneously creates a new custom object record (called the Vehicle object) when a new Opportunity object record is created with a specific Type field value:
trigger createVehicleOnOpportunityX on Opportunity (after insert) { List <Vehicle__c> vehToInsert = new List <Vehicle__c> (); for (Opportunity o : Trigger.new) { if (o.Type == 'NS-TO (New Sale - Task Order Contract)') { Vehicle__c v = new Vehicle__c (); v.Name = o.Name; v.Vehicle_HEGR__c= o.Historical_EGR__c; v.Vehicle_Amount__c = o.Amount; v.Vehicle_Recompete__c = o.Is_Recompete__c; v.Vehicle_Gross_Capacity__c = o.Gross_Capacity__c; v.Vehicle_Stage__c = o.StageName; vehToInsert.add(v); }//end if }//end for o try { insert vehToInsert; } catch (system.Dmlexception e) { system.debug (e); } }
Here is the code snippet, hope this will help you.
Thanks
Ankit Arora
Blog | Facebook | Blog Page