function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Formula field not being calculated in SOQL queries?

I have a nightly Apex batch that is rather simple in my mind. For whatever reason, I am getting errors now several weeks after being implemented I would have thought been caught by now.  

The error I'm getting is "TRANSFER_REQUIRES_READ, The new owner must have read permission."  This error itself isn't a concern.  It makes complete sense.  

Basically the batch job is looking for records where the owners of ObjectA__c and ObjectB__c are different.  If they are, update ObjectA__c's Owner to ObjectB__c's.  The error being raised is a result of ObjectB__c's owner no longer being active within SFDC.

Looking at the records for the Users, ObjectA and ObjectB, I am finding no modifications in the past 24 hours that would have hit the criteria of the SOQL query.  Some of the records haven't been touched in several months.  This leads me to think that the formula field sometimes isn't being calculated during batch runs.  Has anyone seen this type of thing before?


SELECT id, OwnerId, ObjectB__r.OwnerId FROM ObjectA__c WHERE
Ownership_Same__c = FALSE AND RecordType = Type1 AND ObjectB__c != NULL

Formula Field
If(OwnerId = ObjectB__r.OwnerId, TRUE, FALSE)
PriyaPriya (Salesforce Developers) 
Hi PugetSoundJim,

What is the relationship between the two objects?

Hi Ranjan - 

Object B is just a lookup on Object A.