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
Max Michael Ingraham-RakatanskyMax Michael Ingraham-Rakatansky 

Visualforce Page - Restrict Child Record Types option based on Parent Record Type

Hello,

We have a custom button in our Salesforce environment that links to a Visualforce page for creating a new related custom object record. I am looking for a way to restrict the record type options of the child object based on the parent object's record type. While I am not the one who designed the code, I have some basic understanding of Visualforce and Apex, and have made some modifications to our org's code in the past. 

Do you know the best way to go about this? Would this change be reflected in Visualforce or Apex?

VF Page
<apex:page name="Confirm Investigation" standardcontroller="case" extensions="CasetoAccountContactDDQ">
<style type="text/css">
    .pbTitle {
        white-space: nowrap;
    }
</style>
<script>
    function goCancel(){
        window.top.location='/{!case.id}';
    }
</script>
<apex:form >
   
 <apex:pageMessages />
<apex:pageBlock title="Select DDQ Type" id="mainBlock">
       <apex:pageBlockButtons location="Bottom">
             <apex:commandButton value="Cancel" onclick="goCancel();return false;"/>  
            <apex:commandButton value="Send DDQ" action="{!createObjs}"   />      
       </apex:pageBlockButtons>
   <!--<apex:outputText value="{!newcase.AccountId}" style="font-size:11px;font-weight:bold;color:blue" />--->
       <br/>
       <apex:outputPanel >
           <apex:pageBlockSection columns="2">
               
               <apex:inputField value="{!dueDateCase.DDQ_Due_Date__c}"/>
           </apex:pageBlockSection>
       </apex:outputPanel>
       
       <apex:outputPanel >
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           <Strong>DDQ Type&nbsp;&nbsp;:&nbsp;&nbsp;</strong>
                      <apex:selectList value="{!selectedDDQType}" size="1" required="true">
               <apex:selectOptions value="{!DDQRecordTYpesSelect}"/>
           </apex:selectList>
       </apex:outputPanel>
       
       
       <br/>
</apex:pageBlock>
<br/>
<br/>
<br/>
<!--
<h2>Available DDQ Types</h2>
<br/>
<table style="font-size:15px;border: 1px solid hsl(252, 4%, 26%) !important;">
<thead>
<tr><th style="background:e0e3e5;border-right:1px solid hsl(252, 4%, 26%) !important;border-bottom:1px solid hsl(252, 4%, 26%) !important;">&nbsp;&nbsp;<Strong style="font-weight: bold !important;">Name</strong></th><th style="background:e0e3e5;border-bottom:1px solid hsl(252, 4%, 26%) !important;">&nbsp;&nbsp;<strong style="font-weight: bold !important;">Description</strong></th></tr>
</thead>
<tbody>
<apex:repeat value="{!recordTypeList}" var="rt">
    
    
    <tr><td style="border-right:1px solid hsl(252, 4%, 26%) !important;border-bottom:1px solid hsl(252, 4%, 26%) !important;">&nbsp;&nbsp;{!rt.name}&nbsp;&nbsp;</td><td style="border-bottom:1px solid hsl(252, 4%, 26%) !important;">&nbsp;&nbsp;{!rt.description}&nbsp;&nbsp;</td></tr>
    
</apex:repeat>
</tbody>
</table>
-->

</apex:form>
<style>
    .tbl{
        background: #f2f3f3;
        color: #000;
        font-size: .15em;
        font-weight: bold;
        border-bottom: 1px solid #e0e3e5;
    }
</style>

</apex:page>

Thanks,
Max