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
Steve HuseSteve Huse 

How do I get my Apex trigger?

Hi All,

 

We use SF Professional edition with API and Workflow enabled.

 

I've become quite conversant with the administration of our Org since we adopted a year ago, but we now need an Apex trigger to automatically create a case when opportunity status = closed won, and am not really sure how to go about it.

 

Is the trigger something that can be written and added to our Org from the admin setup panel, and if not, please can someone let me know how I get this trigger written and added?

 

Thanks in advance.


Steve

JBabuJBabu

Hi Steve,

 

 

Here you go: (you need to go to customize->opportunities->triggers  and add the below code)

 

 

trigger autoCasecreation on opportunity(after update){

List<case> caseList = new List<Case>();

for(Opportunity opp: trigger.New){
    if(opp.stageName=='Closed Won' && opp.stageName != System.Trigger.OldMap.get(opp.id).stageName ){
        Case cs = new case();
        caseList.add(cs);
     }

    if(!caseList.isEmpty()){
      insert CaseList;
    }
 }
}

 

Thanks,

JBabu.

Steve HuseSteve Huse

Perfect ... except !

 

customize->opportunities-> no 'triggers' link ?

 

We're using Professional edition with Workflow and API enabled ... do I need to get Apex functionality enabled?

 

Thanks

 

Steve