1

Someone previously set up an APEX trigger for my org and the custom object is not working when triggered because the trigger is inactive. It looks like people have had issues previously with the ability to activate a trigger. I'm not sure if I should start over and have this inactive trigger in production or try to fix the current trigger. Screenshots below. Trigger nameTrigger Trigger here:

trigger createOnboardingOnOpportunityWon on Opportunity (after update) {

List <Onboarding__c> OnboardingToInsert = new List <Onboarding__c> ();
// or whatever your custom object name put instead of Sponsorship__c

for (Opportunity o : Trigger.new) {


// here is where you check if opportunity that is being inserted
//meets the criteria
if (o.StageName == 'Closed Won'){

Onboarding__c b = new Onboarding__c (); //instantiate the object to put values for future record

// now map opportunity fields to new vehicle object that is being created with this opportunity

b.Name = o.Name; // and so on so forth untill you map all the fields.
b.Account__c = o.AccountId;
//Monthly_Transactions__c
//Current_Software_Platform__c
//Operating_States__c
//Underwriters__c
//Number_of_employees__c
//Pains__c
//LeadSource

//**Next Step = "Send intro email"


//once done, you need to add this new object to the list that would be later inserted.
//don't worry about the details for now

onboardingToInsert.add(b);


}//end if

}//end for o

//once loop is done, you need to insert new records in SF
// dml operations might cause an error, so you need to catch it with try/catch block.
try {
insert OnboardingToInsert;
} catch (system.Dmlexception e) {
system.debug (e);
}

enter image description here

3
  • 1
    First thing you would do is identify why this trigger is deactivated. What were the possible errors they could get by this trigger. Perhaps we can help you to fix this itself.
    – Ashwani
    Commented Jan 23, 2017 at 2:31
  • @martin I never faced this behavior (the link you provided). Is this really happen today also?
    – Ashwani
    Commented Jan 23, 2017 at 3:29
  • @Ashwani it looks like they fixed that, nevermind.
    – martin
    Commented Jan 23, 2017 at 3:32

1 Answer 1

0

It does not appear to me that anything internal to this trigger would cause a problem...leading me to believe that the reason for its deactivation would be found elsewhere in your org or have some relation to all the commented items that are not rendered as methods or additions. Depending upon your specific requirements for performance, you may want to remove the try/catch block and sub

database.saveResult[] sra = database.insert(onboardingtoinsert, false);

You can then iterate the results, or no, to find out which records fail and why. Review saveResult class for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .