• Cody Drennon 7
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Below i am trying to replace User.Name with the name of my picklist field(Change_Owner__c) and then Cody Dren with whatever the user selected from the picklist(Cody D, Kyle W, Jen J etc).  Can someone please help me with this. 

Thanks.

Trigger UpdateOwnerID on Case (before insert, before update) {
       
    User objUser = [select Id from User where User.Name = 'Cody Drennon' limit 1];  
    for (Case objCase : Trigger.new)
    {
        if (objCase.OwnerId <> objUser.Id)               
        {
            objCase.OwnerId = objUser.Id;
        }
    }

}
Below i am trying to replace User.Name with the name of my picklist field(Change_Owner__c) and then Cody Dren with whatever the user selected from the picklist(Cody D, Kyle W, Jen J etc).  Can someone please help me with this. 

Thanks.

Trigger UpdateOwnerID on Case (before insert, before update) {
       
    User objUser = [select Id from User where User.Name = 'Cody Drennon' limit 1];  
    for (Case objCase : Trigger.new)
    {
        if (objCase.OwnerId <> objUser.Id)               
        {
            objCase.OwnerId = objUser.Id;
        }
    }

}