System.SObjectException: SObject row was retrieved via SOQL without querying the requested field:
This kind of exception that happens when we are trying to access one object property that actually we haven't got through an SOQL query.
Let me explain.
If an Object Lead has Id,Name,Email with it. And if we are writing the below query to retrieve its Id, Name from the object.
Ld = [select Id,Name from lead];
if you then access Email property from the Ld instance , sales force will throw the error System.SObjectException: SObject row was retrieved via SOQL without querying the requested field:
To avoid retrieve all the required [here it's email] field in your SOQL query