+ Start a Discussion
KimKim 

Lightning:inputField does not show picklist values based on record type

Hello,

Has anyone been able to successfully show picklist values based on record type using lightning components? We have 4 record types and for some reason all record types is defaulting to the RSO record type picklist values.

This is what I have so far and it is not displaying the correct picklist values based on the record type.

Parent Component:
<aura:component controller="BusinessRequest_LightningController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes" access="global">
    
    <!--Initialization-->
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    
    
    <!--Attribute Setup-->
    <aura:attribute name="isOpen" type="Boolean" default="false"/> 
    <aura:attribute name="simpleRecord" type="Object"/> 
    <aura:attribute name="record" type="Object"/>
    
    <!--Record Type Attributes-->
    <aura:attribute name="recordTypeMap" type="Map"/>   
    <aura:attribute name="recordTypeChoice" type="String" default="-- None --"/>
    <aura:attribute name="recordTypeId" type="Id"/>   
    
    <!--Field Attributes-->
    <aura:attribute name="category" type="String"/>  
    <aura:attribute name="subcategory" type="String"/>    
    <aura:attribute name="status" type="String"/>      
    <aura:attribute name="subject" type="String"/>      
    <aura:attribute name="description" type="String"/>      
    <aura:attribute name="steps" type="String"/>
    <aura:attribute name="email" type="String"/> 
    <aura:attribute name="date" type="Date"/>
    <aura:attribute name="comments" type="String"/>
    
    
    <!--Object Field Retrieval-->
    
    <force:recordData aura:id="objectFields"
                      recordId="{!v.recordId}" 
                      layoutType="FULL"
                      targetRecord="{!v.record}"
                      targetFields="{!v.simpleRecord}"
                      mode="VIEW"/>
    
    <!-- Title -->
    
    <div class="slds-grid">
        <div class="slds-col slds-has-flexi-truncate">
            <p class="slds-text-heading--large">Business Request</p>
            <div class="slds-grid" style="background-color: #F4F6F9;">
                <div class="slds-grid slds-type-focus slds-no-space">
                    <h1 class="slds-text-heading--medium slds-truncate" style="font-weight: bold;" title="Business Request Quick Create">Quick Create</h1><br/><br/>
                </div>
            </div>
        </div>
    </div>
    
    <!--Main Form--> 
    <form id="mainForm" class="slds-form--stacked">
        <aura:if isTrue="{!v.isOpen}"> 
            
            <!--Record Type Selection-->
            <div class="slds-form-element slds-is-required">
                <div class="slds-form-element__control" style="width: 175px;">
                    <ui:inputSelect aura:id="recordTypes" 
                                    class="slds-input"
                                    labelClass="slds-form-element__label"               
                                    value="{!v.recordTypeChoice}"
                                    required="true"
                                    change="{!c.getRecordTypeId}"/><br/><br/>
                </div>
            </div>
    
            <!--RSO Request-->
            <aura:if isTrue="{!v.recordTypeChoice == 'RSO'}">
                <c:BusinessRequest_RSO recordTypeId="{!v.recordTypeId}"
                                       recordTypeMap="{!v.recordTypeMap}"
                                       category="{!v.category}"
                                       comments="{!v.comments}"
                                       email="{!v.email}"
                                       date="{!v.date}"/> 			  
                
            </aura:if>
            
            <!--Legal Request-->
            <aura:if isTrue="{!v.recordTypeChoice == 'Legal'}">
                <div aura:id="legalRecord" class="slds-show">
                    <c:BusinessRequest_LegalRequest />			  
                </div>
            </aura:if>
            
            
            <!--Commision Dispute--> 
            
            <!--Sales Ops-->		
            <aura:if isTrue="{!v.recordTypeChoice == 'Sales Operations'}">  
                <c:BusinessRequest_SalesOps recordTypeId="{!v.recordTypeId}"
                                            category="{!v.category}"
                                            subcategory="{!v.subcategory}"
                                            status="{!v.status}"
                                            subject="{!v.subject}"
                                            description="{!v.description}"
                                            steps="{!v.steps}"/>
            </aura:if>
            
            
        </aura:if>
    </form>
    
    
</aura:component>

RSO Child Component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes" access="global">
    
    <!--Attribute Setup-->
    <aura:attribute name="showRecordType" type="Boolean" default="false"/>
    <aura:attribute name="recordTypeId" type="Id"/> 
    <aura:attribute name="recordTypeMap" type="Map"/>
    <aura:attribute name="email" type="String"/>
    <aura:attribute name="date" type="Date"/>
    <aura:attribute name="category" type="String"/>
    <aura:attribute name="comments" type="String"/>
    
    <!--RSO Business Request Form--> 
    <div aura:id="rsoComponent">
      
                <!--Lightning Input Field-->
        
                <lightning:recordEditForm aura:id="rsoRecordCreate"
                                          recordTypeId="{!recordTypeId}"
                                          objectApiName="Business_Request__c">
                    <lightning:inputField aura:id="email" fieldName="LMI_Email__c"/>
                    <lightning:inputField aura:id="date" fieldName="Request_Date__c"/>
                    <lightning:inputField aura:id="category" fieldName="Category__c"/>
                    <lightning:inputField aura:id="subcategory" fieldName="Sub_category__c"/>
                    <lightning:inputField aura:id="comments" fieldName="Comments__c"/>
                </lightning:recordEditForm>
           
    </div>
    
    
    <!--Record Type Selection--> 
    <aura:if isTrue="{!v.showRecordType}"> 
        <c:BusinessRequest_QuickCreate />
    </aura:if>    
    
</aura:component>

Sales Ops Child Component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes" access="global">
    
    <!--Attribute Setup-->
    
    <aura:attribute name="recordTypeId" type="Id"/> 
    <aura:attribute name="recordTypeMap" type="Map"/>    
    <aura:attribute name="category" type="String"/>    
    <aura:attribute name="subcategory" type="String"/>     
    <aura:attribute name="status" type="String"/>      
    <aura:attribute name="subject" type="String"/>      
    <aura:attribute name="description" type="String"/>      
    <aura:attribute name="steps" type="String"/>
    
    <!-- Sales Operations Business Requests Form --> 
    
    <div aura:id="salesOpsComponent"> 
        <!-- Input Fields -->
        <lightning:recordEditForm aura:id="salesOpsRecordCreate"
                                      recordTypeId="{!recordTypeId}"
                                      objectApiName="Business_Request__c">
            <div class="slds-form" role="list" style="width:700px;">
                <div class="slds-grid slds-gutters_small">
                    <div class="slds-col slds-has-flexi-truncate" role="listitem">
                        <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                            <div class="slds-form-element__control">
                                <lightning:inputField aura:id="category" fieldName="Category__c"/>
                            </div>
                        </div>
                    </div>
                    <div class="slds-col slds-has-flexi-truncate" role="listitem">
                        <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                            <div class="slds-form-element__control">
                                <lightning:inputField aura:id="subcategory" fieldName="Sub_category__c" value="{!v.subcategory}"/><br/><br/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="slds-grid slds-gutters_small" style="width: 360px;">                
                    <div class="slds-col slds-has-flexi-truncate" role="listitem">
                        <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                            <div class="slds-form-element__control">
                                <lightning:inputField aura:id="status" fieldName="Status__c" value="{!v.status}"/><br/><br/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="slds-grid slds-gutters_small">
                    <div class="slds-col slds-has-flexi-truncate" role="listitem">
                        <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                            <div class="slds-form-element__control">
                                <lightning:inputField aura:id="subject" fieldName="Subject__c" value="{!v.subject}"/><br/><br/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="slds-grid slds-gutters_small">
                    <div class="slds-col slds-has-flexi-truncate" role="listitem">
                        <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                            <div class="slds-form-element__control">
                                <lightning:inputField aura:id="description" fieldName="Description__c" value="{!v.description}"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </lightning:recordEditForm>   
    </div>
    <!-- End Sales Operations Business Requests Form --> 
</aura:component>


 
sachinarorasfsachinarorasf
Hi Kim,

I have gone through your problem.

Here is the code you can use and update as per your requirements. And must check the fields are available or not in your respective record type. 
 
Component:-code

<aura:component >
    <aura:attribute name="recordTypeId" type="string"/>
    <aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
    <lightning:recordEditForm recordTypeId = '{!v.recordTypeId}' objectApiName="Account">
        <lightning:inputField fieldName="Name"/>
        <lightning:inputField  fieldName="Acc_Satus__c"/>
        <lightning:inputField  fieldName="FiledPicklist__c"/>
    </lightning:recordEditForm>
</aura:component>

Controller:

doInit : function(c, e, h) {
    c.set('v.recordTypeId', '0122v000001ptDMAAY');
},

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora