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
MSSBMeghanMSSBMeghan 

Syntax Error on Contract Trigger

Apologies in advance - I know this is a small syntax error, but I can't seem to solve this on my own.  I get a comple error with the following trigger (designed to create new Contract on closed opportunity if a contract does not already exist)

 

Unfortunately I just accidentally closed my browser window where I was writing this, so I don't know the exact error - I just remember it was a compile error on line 3.

 

Any help would be most appreciated!!

 

trigger checkOppty on Opportunity(after update) { private List<Contract> contracts = new List<Contact>(); for (Opportunity o in Trigger.new) { if (o.isClosed && !Trigger.oldMap.get(o.Id).isClosed) { Contract c = new Contract(Name = o.Name); contracts.add(c); } } if (contracts.size() > 0) { insert contracts; } }

 

visulaforcevisulaforce

Pls check

 

 for (Opportunity o in Trigger.new) {

 

This will be

 

 for (Opportunity o : Trigger.new) {