You need to sign in to do that
Don't have an account?

SObject row was retrieved via SOQL without querying the requested field
Hello,
I am following a simple sample from https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
My code looks like this:
When I run this, I get the following error:
Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Lead.FirstName
Can anyone please assist me with this?
Thank you in advance.....
I am following a simple sample from https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
My code looks like this:
public with sharing class LeadController { private final Lead ldObj; //public Lead ldObj{get;set;} public LeadController(ApexPages.StandardController controller) { //Fetching the Current Lead Record this.ldObj = (Lead)controller.getRecord(); } public Component.Apex.SectionHeader getoutPanel() { date dueDate = date.newInstance(2011, 7, 4); boolean overdue = date.today().daysBetween(dueDate) < 0; Component.Apex.SectionHeader sectionHeader = new Component.Apex.SectionHeader(); if (overdue) { sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!' + ldObj.FirstName; return sectionHeader; } else { sectionHeader.title = 'Form Submission'; return sectionHeader; } } }
When I run this, I get the following error:
Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Lead.FirstName
Can anyone please assist me with this?
Thank you in advance.....
Change this:
sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!' + ldObj.FirstName;
To this:
sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!';
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardcontroller.htm#apex_ApexPages_StandardController_addFields
public LeadController(ApexPages.StandardController controller)
{
// Add Reference Fields
List<String> lists = new List<String>();
lists.add('FirstName');
controller.addFields(lists);
//Fetching the Current Lead Record
this.ldObj = (Lead)controller.getRecord();
}
Please let us know if above solution help u
Thanks,
Amit Chaudhary
Can you help me with proper syntax, please? Seems like the field needs to be in the query.
Current code:
public static void AddOrderNumber(Map<Id, Order__c> oldMap,list<Order__c> issListIn,boolean isnew,boolean isODSvccall) {
// List<Order__c> issListIn = [select id,Order_Number__c, from Order__c where id in :Ordermap.keyset()];
*The Query is in the commented line. Trying to save it, but unable to do so