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
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. 


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 :{
             if(opp.Status == won && opp.Stage == picklistValue){
                     opp.Account Status = 'set to value'

       update l1;

Cyrus T
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