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
angusgrantangusgrant 

SOQL runs in Apex Explorer 8 but errors in custom apex class

Hi I have created the following SOQL query:

 

 

Select a.Application__c, a.Application__r.LastModifiedById, a.Attended_Session__c, a.Event_Session__c from App_Session__c a Where a.Application__r.SBS_event__c = 'a018000000MC48UAAT' and Event_Session__c = 'a0580000005lAMXAA2'

 

 

 

Which runs fine in Apex Explorer.

 

However when I put it into an apex class controller and attempt to return it as a list I get the following error:

Error: Invalid field Applicant__r for SObject App_Session__c

 

public class attendeesbyeventcontroller { string eventID = System.currentPageReference().getParameters().get('id'); public string eventsessions { get; set;} public List<App_Session__c> getApplicant() { return [Select a.Application__c, a.Application__r.App_Sessions_Attended__c, a.Application__r.Applicant_Email__c, a.Application__r.Applicant_Name__c, a.Attended_Session__c, a.Event_Session__c from App_Session__c a Where a.Application__r.SBS_event__c = :eventid and Event_Session__c ='a0580000005lAMXAA2' Limit 40]; } }

 

 Can anyone help me with this?

 

 

 

Walter@AdicioWalter@Adicio
Try looking at the schema for the fields in the object 'App_Session__c" and reference what it lists as the 'Foreign Key' for the 'Application' field. Probably " Application__c.LastModifiedById " . That would be if "Application__c" is the related-to field for the child records in object "Application__c" related to the parent record in object " App_Session__c ".