function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sk aleemsk aleem 

create a new trigger on opportunity which will set the stage name is prospecting and close date is 15 days from today.

Shawn Reichner 29Shawn Reichner 29
Try the below...hasnt been compiled, but will get you in the ballpark and on your way. 

trigger OpportunityTrigger on Opportunity (before insert){
List<Opportunity> opps = new List<Opportunity>();
for(Opportunity o : Trigger.new){
     o.Stage = 'Prospecting';
     o.CloseDate = Date.Today()+15;
     opps.add(o);
}
If(opps.size()>0){
insert opps;
}
}
Deepali KulshresthaDeepali Kulshrestha
Hi Aleem,

Try the following code, it may be helpful for you:
Trigger:
trigger OpportunityTrigger on Opportunity (before insert){
        if(trigger.isInsert && trigger.isBefore){
        OpportunityTriggerHandler.OpportunityTriggerMethod(trigger.new);
        }
}
Trigger-Handler:
public class OpportunityTriggerHandler {
    public static void OpportunityTriggerMethod(List<Opportunity> oppList){
    for(Opportunity opp : oppList){
         opp.StageName = 'Prospecting';
         opp.CloseDate = Date.Today()+15;
    }
}
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Ajay K DubediAjay K Dubedi
Hi sk,
The trigger can be like this:
 
trigger OpportunityTrigger on Opportunity (before insert){
for(Opportunity obj : Trigger.new){
     obj.Stage = 'Prospecting';
     obj.CloseDate = Date.Today().addDays(15);
}
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi