+ Start a Discussion
Shane QuiringShane Quiring 

What is the child relationship name for service contract?

Hello Experts,

I am writing a VF Page (Tabbed) and I am working with Service Contracts. I have a related list for a related Service Contract on the Service Contract. Different records types of course. I keep getting the error: 'ServiceContract' is not a valid child relationship name for entity Service Contract. Here is the coding:

<apex:page standardController="ServiceContract" showHeader="true" 
        tabStyle="servicecontract" >
<center>
        <apex:outputPanel style="background-color:red;width:100%;padding:20px;" 
    rendered="{!ServiceContract.Record_Type_Name__c=='Client Contract'}">
    <style>
h1 {
    font-size: 20px;
}
</style> 
        <h1>CLIENT CONTRACT!</h1>
    </apex:outputPanel>
    </center>
    <center>
        <apex:outputPanel style="background-color:red;width:100%;padding:20px;" 
    rendered="{!ServiceContract.Record_Type_Name__c=='Supplier Contract'}">
    <style>
h2 {
    font-size: 20px;
}
</style> 
        <h2>SUPPLIER CONTRACT!</h2>
    </apex:outputPanel>
    </center>
        <style>
      .activeTab {background-color: #236FBD; color:white; 
         background-image:none}
      .inactiveTab { background-color: lightgrey; color:black; 
         background-image:none}
   </style>
   <apex:tabPanel switchType="client" selectedTab="tabdetails" 
                  id="ServiceAccountTabPanel" tabClass="activeTab" 
                  inactiveTabClass="inactiveTab">   
      <apex:tab label="Details" name="ServiceAcctDetails" id="tabdetails">
         <apex:detail relatedList="false" title="true"/>
      </apex:tab>
      <apex:tab label="Approval History" name="ApprovalHistory"
                 id="tabApprovalHist">
          <apex:relatedList subject="{!servicecontract}"
                          list="ProcessSteps" />
      </apex:tab>
            <apex:tab label="Notes and Attachments" name="NotesAndAttachments"
                 id="tabNotesAndAttachments">
          <apex:relatedList subject="{!servicecontract}"
                          list="CombinedAttachments" />
      </apex:tab>
            <apex:tab label="Field History" name="FieldHistory" 
                id="fieldhistory">
<apex:outputLink value="https://cs9.salesforce.com/_ui/common/history/ui/EntityHistoryFilterPage?id={!servicecontract.id}">
click to view field history
    </apex:outputLink>
        </apex:tab>
        <apex:tab label="Supplier Contracts" name="SupplierContracts"
                 id="tabSupplierContracts">
          <apex:relatedList subject="{!servicecontract}"
                          list="ServiceContract" />
      </apex:tab>
      </apex:tabPanel>
</apex:page>

The related list exists on the page layout and all users have acces to it. Does anyone know the Child Relationship name for Service Contracts? Any assistance would be greatly apperciated, thank-you.

v/r
Shane
Best Answer chosen by Shane Quiring
Shane QuiringShane Quiring
Hi Deepak,

Ok I finally figured it out. The child relationship name for Service Contracts, if related back onto itself, is Service_Contracts__r. Now all I have to do is figure out how to code the VF page to recognize which record type it is on and only show the related lists for that specfic record type. 

Thank-you for your assistance on this issue.

v/r
Shane

All Answers

Deepak Kumar ShyoranDeepak Kumar Shyoran
Have you tried servicecontracts ?
Shane QuiringShane Quiring
HI Deepak,

Yes I have, I have also tired the following:

Servicecontract
serviceContract
ServiceContract
Service.Contract
Service_Contract
service_contract
Service_contract
service_Contract

Any thoughts?

v/r
Shane
Deepak Kumar ShyoranDeepak Kumar Shyoran
ServiceContracts is the child relationship name for ServiceContract Object, for more reference please visit ​https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AhraIAC 
Shane QuiringShane Quiring
Hi Deepak, 

Unfortunately the child relationship for Service Contract Object is not ServiceContracts, please see attached screen shot:

Visualforce Page Error

I have been through all of mine Look-up fields to see if I had changed the name of the child relationship, I did not change the child relationship name in the related list. 

Any thoughts?

v/r
Shane
Shane QuiringShane Quiring
Hi Deepak,

Ok I finally figured it out. The child relationship name for Service Contracts, if related back onto itself, is Service_Contracts__r. Now all I have to do is figure out how to code the VF page to recognize which record type it is on and only show the related lists for that specfic record type. 

Thank-you for your assistance on this issue.

v/r
Shane
This was selected as the best answer