+ Start a Discussion
Ruben Smith 2Ruben Smith 2 

Help with my 1st Trigger

Hello all, 
I am preparing to write my first trigger... I would like to accomplish the follwing:
When the Opportunity is won, based on selection from opportunity stage picklist, I would like to upate the Account Status, also a picklist. 

Thanks!!

Ruben A. Smith
Cyrus TalladenCyrus Talladen
In general, how I would implement this task would be
1) check if the oopportunity status is "won"
2) check if stage is set to a certain value
3) if both are true then set the Account_Status field
for example:
 
trigger oppTrigger  on Opportunity (after insert, after update){


   if(trigger.isAfter) && trigger.isInsert){
      
         List<Opportunity > l1 = new List<Opportunity >()

         for(Opportunity opp : trigger.new){
             
             if(opp.Status == won && opp.Stage == picklistValue){
                     opp.Account Status = 'set to value'
                     l1.add(opp) 
           }
         }

       update l1;



Cyrus T
www.levementum.com
Ruben Smith 2Ruben Smith 2
    Thanks for your prompt response, however when I attmpt to save this trigger in sandbox, the following error appears:

Error: Compile Error: unexpected token: '&&' at line 3 column 22    

thoughts?