Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement