+ Start a Discussion
Julien SalensonJulien Salenson 

Spring 19 : SObject row was retrieved via SOQL without querying the requested field

Hi,

Something strange happend..
 have developp an apex and a test class in Summer 2018.
Eveything was fine. Today, my class are working in production.

But today, I have re-run the test, and I have got 
"SObject row was retrieved via SOQL without querying the requested field".

But the field is in the apex class, in SOQL and test class too.

Does something happend in the last 2 release ?
Khan AnasKhan Anas (Salesforce Developers) 
Hi Julien,

Greetings to you!

I tried to research your problem and found that this is not a known issue.

There can be three possible reasons for this error:

1. When you try to use a field in Apex or visualforce which is not queried. 

2. When accessing a Visualforce page with a standard controller and a custom controller extension.

3. When you do not have permissions to access the field under the object.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas