• Nikhil Shrigod 17
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Can anyone please tell me that how can we display a visualforce page on clicking a button that is on accounts object's detail page?
trigger AccountTransfer on User (before insert)
{
  for(User u2:trigger.new)
  {
    List<Account> acc=[select name,owner.name  from account where owner.name = 'Mario Wade'];
    User u=[select Id from user where name='AB CD'];
    User u1=[select Id from user where name='Mario Wade'];
    
    if(u1.IsActive==false)
    {
        for(Account a:acc)
        {
             a.Owner=u;
            //a.OwnerId=u.id;
        }
    update acc;    
    }
  }
}

Say there are two users:
1)Mario Wade and
2)AB CD
And the owner of the records created of account object is Mario Wade.
Now what i want to do is, when the trigger gets fired, the owner of the account standard object records should get changed from Mario Wade to AB CD.

I have written above code for it, bur the owner of the records isn't getting changed.
So please help.