+ Start a Discussion
sreejasreeja 

error:Error: Compile Error: Didn't understand relationship 'Recepient_information__c' in FROM part of query call.

Error: Compile Error:
Recepient_information__r.Name from Recepient_information__c)FROM Company_Information__c
^
ERROR at Row:1:Column:56
Didn't understand relationship 'Recepient_information__c' 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 6 column 16


 hi i had created a  two custom objects of recepient(child) and companyinformation(parent), and created a masterdetail relationship in child object that is receipent object . if iam querying parent and child records it is showing error , may i know why?? 
 the code is as folows.
public class sample2
{    
    public List<Company_Information__c> acct {get;set;}
    public sample2()
    {
        acct = [SELECT Name,phone__C,(select Recepient_information__r.Name from Recepient_information__c)FROM Company_Information__c ];
    }    
}



visualforce page code is:

<apex:page controller="sample2">
    <script>
function toggleContacts(className){
    elem = document.getElementsByClassName(className)[0];
    if(elem.style.display == 'none')
        elem.style.display = 'block';
    else
        elem.style.display = 'none';
}
</script>

<apex:form >

    <apex:repeat value="{!acct}" var="a">

        <apex:pageBlock title="{!a.Name}">
            <apex:pageBlockButtons location="top">
                <input type="button" onclick="toggleContacts('tbl-{!a.id}');" value="Show/Hide contacts" class="btn" /> 
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:outputField value="{!a.Phone__c}"/>
            </apex:pageBlockSection>

            <apex:outputPanel styleClass="tbl-{!a.id}" style="display:none;">
            <apex:pageBlockTable value="{!a.Recepient_information__c}" var="c">
                <apex:facet name="header">Contacts</apex:facet>
                <apex:column value="{!c.Name}"/>
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlock>

    </apex:repeat>

</apex:form>
</apex:page>

12on click should have to display the records and needs edit the contact name and account name
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

Custom object child relationships end in __r. So the likely relationship name would be Recepient_Information__r. Also, you need to use correct Child Relationship Name. So, your child relationship name should be Recepient_informations.

You can get Child Relationship Name by following below steps:
- Go to Class__c object -> Fields and Relationships -> University Field -> You can see Child Relationship Name

Change your query to:
SELECT Name, Phone__c, (SELECT Name FROM Recepient_Informations__r) FROM Company_Information__c

If the problem still persists, please share the screenshot of relationship field.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas