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
Minhaj Arifin 5Minhaj Arifin 5 

Trigger Error - Why does the 'SObject row was retrieved via SOQL without querying the requested field' error appear?

Hello, 
I am getting this error message in my Conference app when I try to assign a Speaker to a Session, I get this error message. Can you please explain why I am getting this error? I am also pasting the code for the Trigger. Thanks! 

User-added image
User-added image
Best Answer chosen by Minhaj Arifin 5
Amit Chaudhary 8Amit Chaudhary 8
Please update your Query on line number 5 like below and add Session__r.First_Name__c in query.

Session_Speaker__c sessionSpeaker =
 [ Select Session__r.Name,
Session__r.Session_Date__c,
Session__r.Last_Name__c,
Session__r.First_Name__c,
Session__r.Email__c

Let us know if this will help you

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please update your Query on line number 5 like below and add Session__r.First_Name__c in query.

Session_Speaker__c sessionSpeaker =
 [ Select Session__r.Name,
Session__r.Session_Date__c,
Session__r.Last_Name__c,
Session__r.First_Name__c,
Session__r.Email__c

Let us know if this will help you
This was selected as the best answer
Mubeen QawiMubeen Qawi
The field in query is missing, add it as Amit chaudhary commented.
Minhaj Arifin 5Minhaj Arifin 5
Thank you Amit and Mubeen! So as you explained the problem was that I was attemping to use a field in my confirmation email but that field was not part of my query. 

User-added image