+ Start a Discussion
Ram ChaturvediRam Chaturvedi 

How can i change ownership of any custom object record , by using apex code ?

I want to change ownership of any record to the another user so if i am trying to change "owner.id" it gives error not writable .
KaranrajKaranraj
Ram - The API name of the Owner field is "OwnerID". Can try instead of using Owner.Id?
Darshan FarswanDarshan Farswan
Hi Raj

As Karanraj said, you will have to update the OwnerID field and not Owner.Id.

Owner.Id will select the Owner user and try to update its Salesforce ID, which is always Read-Only.