You need to sign in to do that
Don't have an account?
Synthia B.
Apex Class - Compile Error: Didn't understand relationship
I am not sure why I am getting this error when attempting to create this class.
Error: Compile Error: Didn't understand relationship 'Implementation_Task__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 18 column 26
Thanks in advance!
Error: Compile Error: Didn't understand relationship 'Implementation_Task__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 18 column 26
public with sharing class ImplementationTaskReportCtrl { public String PLAN_YEAR_ID; public final String SHOW_IMPTS = 'show'; public List<Implementation__c__c> Implementation{get;set;} public List<Implementation_Task__c> ImplementationTasks{get;set;} public ImplementationTaskReportCtrl () { PLAN_YEAR_ID = Apexpages.currentPage().getParameters().get('Id'); if( PLAN_YEAR_ID instanceof Id ){intialize();} else{Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, Label.Invalid_Id_Error ) );} } private void intialize() { Implementation = [ SELECT Id, Name, Total_Required_Tasks__c, Plan_Year_1__c, Percent_Complete__c, Completed_Tasks__c, ( SELECT Name, Completed__c, Completed_Date__c, Due_Date__c, Current_Notes__c, Historical_Notes__c FROM Implementation_Task__r WHERE In_Reports__c = :SHOW_IMPTS ORDER BY Due_Date__c ) FROM Implementation__c WHERE Plan_Year_1__c = :PLAN_YEAR_ID ]; if( Implementation == NULL || Implementation.isEmpty() ) { Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, Label.No_Plan_Year_Related_IMPs_Error ) ); } else { ImplementationTask = [ SELECT Name, Implementation__c, Completed__c, Completed_Date__c, Due_Date__c, Current_Notes__c, Historical_Notes__c FROM Implementation_Task__c WHERE Implementation__c IN :Implementation AND ( Due_Date__c < TODAY OR Due_Date__c = THIS_WEEK ) AND Completed_Date__c = null ORDER BY Due_Date__c ]; } } public PageReference saveIMPTasksDueThisWeekAndStay () { return save( ImplementationTask, false ); } public PageReference saveIMPTasksDueThisWeekAndGoBack () { return save( ImplementationTask, true ); } public PageReference saveIMPTasksAndStay () { List<Implementation_Task__c> IMPTasksToBeSaved = getAllIMPTasks(); return save( IMPTasksToBeSaved, false ); } public PageReference saveIMPTasksAndGoBack () { List<Implementation_Task__c> IMPTasksToBeSaved = getAllIMPTasks(); return save( IMPTasksToBeSaved, true ); } private List<Implementation_Task__c> getAllIMPTasks () { List<Implementation_Task__c> IMPTasksToBeSaved = new List<Implementation_Task__c>(); for( Implementation__c aIMP : Implementation ) { for( Implementation_Task__c aTask : aIMP.Implementation_Task__r ) { IMPTasksToBeSaved.add( aTask ); } } return IMPTasksToBeSaved; } private PageReference save ( List<Implementation_Task__c> IMPTasksToBeUpdated, Boolean goback ) { try { update IMPTasksToBeUpdated; } catch ( Exception ex ) { Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, ex.getMessage() ) ); return NULL; } return ( goback ? back () : stay() ); } public PageReference back() { return new PageReference ( '/' + PLAN_YEAR_ID ); } private PageReference stay() { intialize(); return NULL; }
Thanks in advance!
The error seems that you you have not create the custom label: No_Plan_Year_Related_IMP_Error.
Go to custom labels and create with the same name. It will resolve the issue. Let me know, if you have any other issue.
Thanks,
Neetu
All Answers
At line no. 18, replace your query like this: As you need to use child relationship name.
Let me know, if you need any other help.
Thanks,
Neetu
yes Neetu is correct you have to use the child relationship name , while doing parent to child relationship queries .
Thanks ,
vishal
And Error: Unknown property 'String.ID'
The error seems that you you have not create the custom label: No_Plan_Year_Related_IMP_Error.
Go to custom labels and create with the same name. It will resolve the issue. Let me know, if you have any other issue.
Thanks,
Neetu