
3 answers
Hi Jennifer,Currently what i understood from above :You have a field on opportunity called Contact_Status__c . You want set value in this field when opportunity stage name is some option . I am assuming Option1 to be the option that you want to set . When Opportunity is closed , you again want to update Contact Status field . Please correct if my understanding is correct.
trigger OpportunityTrigger on Opportunity(before insert , before update){
if(trigger.isBefore && trigger.isInsert){
for(Opportunity OppObj : Trigger.New ){
if(OppObj.stageName == 'Option1'){ //Opportunitu stage name is option 1
OppObj.Contact_Status__c = 'abc';
}
}
}
if(trigger.isBefore && trigger.isUpdate){
for(Opportunity OppObj : Trigger.New ){
if(trigger.oldMap.get(OppObj.id).IsClosed != OppObj.IsClosed && OppObj.IsClosed == true ){ // Opportunity is Closed
OppObj.Contact_Status__c = 'abc';
}
}
}
}
Hope this helps.