I have the following code
accountToUpdate = [select owner.name from Account where owner.name = :sGetOwnerOne];
accountToUpdate.owner.name = sGetOwnerTwo;
update accountToUpdate;
How can I update owner names? Compiler showed me the following error:
Field is not writeable: User.Name
I tried this:
Account a1 = [select owner.name from Account where owner.name = :sGetOwnerOne];
a1.Owner.name = sGetOwnerTwo;
update a1;
But it didn't work
User
with thatName
? You would need to find theUser
record Id first and setOwnerId
based on that...