daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
  2.    
  3.     List<Task> taskList = new List<Task>();
  4.    
  5.     if(Trigger.isAfter){
  6.        
  7.         for(Opportunity opp : Trigger.new){
  8.             if(opp.StageName=='Closed Won'){
  9.                 Task oppTask = new Task(WhatId=opp.Id, Subject='Follow Up Test Task');
  10.                 taskList.add(oppTask);
  11.             }
  12.         }
  13.         insert taskList;
  14.        
  15.     } else {
  16.        
  17.         for(Opportunity opp : Trigger.old){
  18.             if(opp.StageName=='Closed Won'){
  19.                 Task oppTask = new Task(WhatId=opp.Id, Subject='Follow Up Test Task');
  20.                 taskList.add(oppTask);
  21.             }
  22.         }
  23.         insert taskList;
  24.        
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top