0

I am a newbie please bear with me. I need to create a trigger that will prevent the contract to be activated (NOTE: I can create a contract but cannot activate). It will only be activated if the opportunity stage is "Closed Won". I have created a textfield containing the value of the stage. This is my code

trigger ActivateCont on Contract (before update) {
for( Contract cont: Trigger.new){
    if (cont.Status__c =='Closed Won'){
    cont.Active__c = true;
    cont.Status ='Activated';
    }
    else{
    cont.Active__c = false;
    cont.Status ='Deactivated';
    system.debug('Stage is not Closed Won")       
    }

}
}

I need it to be activated ONLY if the ACTIVATE button will be selected in the Contracts object.

  • up!!!!!!!!!!!!!!!!!!!!!!!!!!! – sfdclearner Oct 6 '15 at 6:16
  • Hi Gelay do it using Validation Rule no need for code. – C0DEPirate Oct 7 '15 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.