Skip to main content Take our 5-minute Community Survey. Open now through 4/11/2025. Click here to participate.
Hello

Does anyone know how I could update a Contact Status field to the custom value of "Opportunity" when a new Opportunity is created then update the Status again when the Opportunity is closed?  Note, the Org is Professional Edition so I can't use Workflow Rules for this and I have no experience/knowledge of Triggers.

Any help would be appreciated!
3 answers
  1. Apr 23, 2018, 3:49 PM
    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.

     
Loading
0/9000