Skip to main content
added 130 characters in body
Source Link
Sebastian Kessel
  • 13.2k
  • 12
  • 38
  • 61

Here is my code : if you want to go with apex class ==================Apex

==================Apex Class ======================= public class OpportunityApexClass {

public class OpportunityApexClass {
    
    public static void opportunityTrigger(list<Opportunity> varOpportunity)
    {
        list<Task> varTask = new list<Task>();
     for(Opportunity varopp : varOpportunity)
        {
         if(varopp.StageName == 'Closed Won')
            { 
                Task varTa = New Task();
                varTa.Subject ='Follow Up Test Task';
                varTa.Status ='Not Started';
                varTa.WhatId = varopp.Id;
                 varTask.add(varTa);
            } 
        }
         insert varTask; 
    }
}

}

===================Trigger========================== trigger ClosedOpportunityTrigger on Opportunity (before insert,before update) {

trigger ClosedOpportunityTrigger on Opportunity (before insert,before update) {
    
    if(Trigger.isbefore == True && Trigger.isinsert == True)
    {
        OpportunityApexClass.opportunityTrigger(Trigger.new);   
    }
    if(Trigger.isbefore == True && Trigger.isupdate == True)
    {
        OpportunityApexClass.opportunityTrigger(Trigger.new);
    }

}

}

Here is my code : if you want to go with apex class ==================Apex Class ======================= public class OpportunityApexClass {

public static void opportunityTrigger(list<Opportunity> varOpportunity)
{
    list<Task> varTask = new list<Task>();
 for(Opportunity varopp : varOpportunity)
    {
     if(varopp.StageName == 'Closed Won')
        { 
            Task varTa = New Task();
            varTa.Subject ='Follow Up Test Task';
            varTa.Status ='Not Started';
            varTa.WhatId = varopp.Id;
             varTask.add(varTa);
        } 
    }
     insert varTask; 
}

}

===================Trigger========================== trigger ClosedOpportunityTrigger on Opportunity (before insert,before update) {

if(Trigger.isbefore == True && Trigger.isinsert == True)
{
    OpportunityApexClass.opportunityTrigger(Trigger.new);   
}
if(Trigger.isbefore == True && Trigger.isupdate == True)
{
    OpportunityApexClass.opportunityTrigger(Trigger.new);
}

}

Here is my code : if you want to go with apex class

==================Apex Class =======================

public class OpportunityApexClass {
    
    public static void opportunityTrigger(list<Opportunity> varOpportunity)
    {
        list<Task> varTask = new list<Task>();
     for(Opportunity varopp : varOpportunity)
        {
         if(varopp.StageName == 'Closed Won')
            { 
                Task varTa = New Task();
                varTa.Subject ='Follow Up Test Task';
                varTa.Status ='Not Started';
                varTa.WhatId = varopp.Id;
                 varTask.add(varTa);
            } 
        }
         insert varTask; 
    }
}

===================Trigger==========================

trigger ClosedOpportunityTrigger on Opportunity (before insert,before update) {
    
    if(Trigger.isbefore == True && Trigger.isinsert == True)
    {
        OpportunityApexClass.opportunityTrigger(Trigger.new);   
    }
    if(Trigger.isbefore == True && Trigger.isupdate == True)
    {
        OpportunityApexClass.opportunityTrigger(Trigger.new);
    }

}
Source Link

Here is my code : if you want to go with apex class ==================Apex Class ======================= public class OpportunityApexClass {

public static void opportunityTrigger(list<Opportunity> varOpportunity)
{
    list<Task> varTask = new list<Task>();
 for(Opportunity varopp : varOpportunity)
    {
     if(varopp.StageName == 'Closed Won')
        { 
            Task varTa = New Task();
            varTa.Subject ='Follow Up Test Task';
            varTa.Status ='Not Started';
            varTa.WhatId = varopp.Id;
             varTask.add(varTa);
        } 
    }
     insert varTask; 
}

}

===================Trigger========================== trigger ClosedOpportunityTrigger on Opportunity (before insert,before update) {

if(Trigger.isbefore == True && Trigger.isinsert == True)
{
    OpportunityApexClass.opportunityTrigger(Trigger.new);   
}
if(Trigger.isbefore == True && Trigger.isupdate == True)
{
    OpportunityApexClass.opportunityTrigger(Trigger.new);
}

}