+ Start a Discussion
Victor19Victor19 

Update picklist field in case object when owner lookup field is updated

Hi,

 

I am trying to setup a trigger that fires whenever the owner is changed in a case and the trigger updates the status field.

For some reason, the trigger does not seem to grab the owner field value. Below is my code:

 

trigger OwnerCaseStatus on Case (after update) {

        for(Case cas: Trigger.new){
                Case oldcase = Trigger.oldMap.get(cas.Id);
        If(cas.Owner != oldcase.Owner){
                    cas.Status = 'Open';
   }
}
}

Can someone please point out if I am missing something.

 

Thanks!

Vic

Best Answer chosen by Admin (Salesforce Developers) 
Rahul_sgRahul_sg
use If(cas.OwnerID != oldcase.OwnerID ){

All Answers

Rahul_sgRahul_sg
use If(cas.OwnerID != oldcase.OwnerID ){
This was selected as the best answer
Victor19Victor19
Thanks Rahul! I also had to make it a before update trigger.
Victor19Victor19
Hi Rahul,

Would you by any chance happen to know a way to update a field whenever a case gets auto assigned using auto-assignment rules in Salesforce?