You need to sign in to do that
Don't have an account?
Timothy Smith
Access Results from SOQL in APEX
Syntax help please. I am trying to access the fields in my SOQL search. I am receiving error message:
`System.SObjectException: Invalid field Parent_Project_if_applicable__r.Implementation_status__c for Case`
I verified Relationship name through WorkBench.
My code is:
List<Case> caseList = [SELECT Id, AccountId, Account.Name,Parent_Project_if_applicable__r.Implementation_status__c, Parent_Project_if_applicable__r.PM_Implementation_Status__c, Parent_Project_if_applicable__r.RCM_Implementation_Status__c, Parent_Project_if_applicable__r.Client_Advisor_Email__c FROM Case WHERE AccountId IN :AcctIds]; for(Case cl:caseList){ System.debug(cl.get('Parent_Project_if_applicable__r.Implementation_status__c')); }
You have to refer like below:
for(Case cl:caseList){
System.debug(' ==> '+ cl.getSobject('Parent_Project_if_applicable__r').get('Implementation_status__c'));
}
========================
Otherwise simply you can refer like below :
System.debug(' ==> '+ cl.Parent_Project_if_applicable__r.Implementation_status__c');
Thanks,
Maharajan.C
If the fields' names are correct and still you are getting the error, please check the Field-Level Security of those fields for your profile.
Please mark the Best if it solves your issue.