• Tecnova Admin
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 13
    Replies
Hi,
 I am in a situation where I would like to create a trigger to update account owner. As I am new to triggers I do not have any experience on working with triggers.

My partner portal users requests me a lot through emails to change account owner from admin to their name.

To solve this issue, I created a custom checkbox field called Record_Transfer_Record__c

So now I want to create a trigger if current account owner is Admin and current user has checked the custom checkbox Record_Transfer_Record__c then after he hit the save button then Account Owner get changed from Admin to current user who is checking the checkbox.
I tried this code but hard luck no success :(

trigger AccountOwnerChange on Account (before update)
         {
          if(trigger.isBefore && Trigger.isUpdate)
        {
            for(Account obj: trigger.new)
            {
                if(obj.ownerId = '00590000001OizE')
                {
                 if(obj.Record_Transfer_Request__c == True)
                 
                Account a = [SELECT id, OwnerId FROM Account WHERE id =: Trigger.old[0].Id];
                
                  Trigger.new[0].OwnerId = UserInfo.getUserId();
                   {
                                    


                    
    }            
   }
   }
   }
   }
Please help ..........

 
Hi,
 I am in a situation where I would like to create a trigger to update account owner. As I am new to triggers I do not have any experience on working with triggers.

My partner portal users requests me a lot through emails to change account owner from admin to their name.

To solve this issue, I created a custom checkbox field called Record_Transfer_Record__c

So now I want to create a trigger if current account owner is Admin and current user has checked the custom checkbox Record_Transfer_Record__c then after he hit the save button then Account Owner get changed from Admin to current user who is checking the checkbox.
I tried this code but hard luck no success :(

trigger AccountOwnerChange on Account (before update)
         {
          if(trigger.isBefore && Trigger.isUpdate)
        {
            for(Account obj: trigger.new)
            {
                if(obj.ownerId = '00590000001OizE')
                {
                 if(obj.Record_Transfer_Request__c == True)
                 
                Account a = [SELECT id, OwnerId FROM Account WHERE id =: Trigger.old[0].Id];
                
                  Trigger.new[0].OwnerId = UserInfo.getUserId();
                   {
                                    


                    
    }            
   }
   }
   }
   }
Please help ..........