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
sfdc help 2sfdc help 2 

I am getting this error

Error: Compile Error: Didn't understand relationship 'eMessage__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 230 column 25

my code:

Public static void mostRecentRead (List<eMessage__c> emsgList){
    List<Case> caslst = [Select CaseNumber,Most_Recent_Read__c,(select Name,Is_Read__c from eMessage__r) FROM Case  where Most_Recent_Read__c = false];
     if(caslst != null){
          for(eMessage__c m : emsgList){ 
                cas = [select id,casenumber,Most_Recent_Read__c from case where id =: m.Case_Number__c limit 1];
                if(cas != null)                  
                cas.Most_Recent_Read__c = true;                    
          }        
      update(cas);
    }
  }  

}

Actually this code is written for to update most recent read check box in case whenever Read field in eMessage(custom Object) is checked manually . If the eMessage object has the attachment and that attachment is read and manually checked Read checkbox in eMeassage object then the most recent read check box in case should update(as checked) automatically.

Please anyone help me out its urgent!!!!!
Art SmorodinArt Smorodin
Hi, 

chack out this resiurce http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_relationships.htm

I think your error is die to the fact that __r is for going 'up', while you're trying to go 'down' the relationship..

-Art.
BalajiRanganathanBalajiRanganathan
Try with eMessages__r on your SOQL. it should be same as the <child relationship name>__r. you can check the child relation ship name on the relation ship field details on the child object (emessage__c).

also your code is not optimized. you have SOQL inside for loop (select id,casenumber,Most_Recent_Read__c from case ). 

1) Get the set of casenumber
2) use SOQL with in to get all the cases into map.
3) Get the case using map