+ Start a Discussion
Admin YakkalaAdmin Yakkala 

Why I can't change OwnerId to null or Empty

Sainath VenkatSainath Venkat
Hello Admin Yakkala,

All Records in Salesforce must have an Owner which is either a User or a Queue, if you try and set OwnerId to Null or blank "", this will always fail as the field is mandatory therefore Null is not an acceptable value.
As the Salesforce security model for data is built around record ownership this is correct behaviour as it will mean that any relevant users are able to access the record. The record owner will be important for the record visibility due to the role hierarchy, OWD and sharing rules so it would be a problem to make have a null or empty value.
Admin YakkalaAdmin Yakkala
I'm trying via Batch Apex update Account field OwnerId to empty (or null) value. But it impossible. If I set a "" (empty value string) to field OwnerId -Error: invalid id: . If I set "null" to this field - update falling with INVALID_CROSS_REFERENCE_KEY. Heed help, thx!
Sainath VenkatSainath Venkat
yes, you cannot create or update record without a owner, doesn't matter whether you are using batch apex or anything else but you need to provide the data into owner field otherwise record insertion will get failed.

You need to provide user id into the field since it is a lookup field on account object to user, you cannot provide Owner=null, you should rpovide a valid user id.

Hope it helps.