I am trying to get the selected value of picklist. This picklist is inside a HTML table and the picklists are dynamically created.

<aura:iteration items="{!v.oppRecordTypeMappingList}" var="item">
                        <td data-label="" title="">{! item.Name}</td>
                        <td data-label="" title="">{! item.Source_Opp_Record_Type_Name__c}</td>
                        <td data-label="" title="">
                            <div class="slds-select_container"> 
                                <ui:inputSelect class="slds-select" aura:id="inputSelectRecType">
                                    <!-- <aura:iteration items="{!v.recordTypeList}" var="i" indexVar="index">
                                        <ui:inputSelectOption text="{!i.Name}" label="{!i.Name}" value="{! i.Name == item.Renewal_Opp_Record_Type_Name__c}" />
                                    </aura:iteration> -->
                                    <ui:inputSelectOption text="ABC" label="XYZ" />
                                    <ui:inputSelectOption text="DEF" label="DEF" value="true" />


I get the picklist value if I hardcode the picklist options. But when options are populated using aura:iteration,

var elem = component.find('inputSelectRecType');

returns undefined.

Can someone point out what am I doing wrong?


You need to PREDEFINE the property that you are going to bind to.

<aura:attribute name="lead" type="Lead" 
              default="{ 'sobjectType':'Lead', 'LeadSource' : ''}" />

Make your input select:

<ui:inputSelect class="slds-select spear-select" aura:id="leadSource" value="{!v.lead.LeadSource}" 
                updateOn="change" label="Lead Source" labelClass="slds-form-element__label " 
                requiredIndicatorClass="slds-required" required="true" >
  <aura:iteration items="{!v.leadSourceValues}" var="source">
    <ui:inputSelectOption text="{!source.value}" label="{!source.label}" />

Then you can extract the value from lead attribute:

var lead = cmp.get("v.lead");
  • Thank you! This is it! I am setting the value on ui:inputSelect from controller init method and now its working. – Ashish Narkhede Jul 7 '16 at 20:21

Solved it partially! If I make change to picklist, then above code prints selected value. However if I don't change the selected value, it still prints undefined.

Is this an expected behavior?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.