Currently, I'm iterating through a wrapper that includes sourceId (aka accountId) and Opportunity Name, etc. When the user selects a radio button, I want to capture that sourceId in an attribute at the top of my component called "accountId".

    selectAccountRadioGroupOnChange : function(component, event, helper) {
    helper.setAccountId(component, helper);

The JS Helper is attempting to get the value attribute on the specific Radio Button that was selected.

    setAccountId : function(component, helper) {
    var accountIdOnRadioButton =  component.get("v.selectAccountRadioGroup");    
    component.set('v.accountId', accountIdOnRadioButton); 
    console.log('accountIdOnRadioButton', accountIdOnRadioButton);

You can see the console.log returns 'undefined' enter image description here

<aura:component access="public" implements="force:appHostable,lightning:isUrlAddressable" controller="MyController">    
<!--<aura:attribute name="organizationWrappers" type="List" default=""/>-->
<aura:attribute name="compositeWrapper" type="Object" />  
<aura:attribute name="options" type="List" default="[{'label': '', 'value': 'option1'}]"/>
<aura:attribute name="value" type="String"/>
<aura:attribute name="accountId" type="String"/>

Note I'm trying to set value here to {!organization.sourceId}, which is the Account ID. This would allow me to then get that Account Id later. (Also, note here: onchange="{!c.selectAccountRadioGroupOnChange}")

        <aura:iteration items="{!v.compositeWrapper.organizations}" var="organization">
                <td scope="row">
                    <lightning:radioGroup name="selectAccountRadioGroup"
                    <!--accountId = "{!organization.sourceId}"-->
                    <lightning:formattedDateTime value="{!organization.lastPurchaseDate}"/>
  • selectAccountRadioGroupOnChange.js can you share its code
    – User6670
    Commented Feb 12, 2020 at 20:32
  • Thanks @User6670, I just added it to the body here. Commented Feb 12, 2020 at 20:40
  • why are you using lightning radio group you can just use lightning input of type radio
    – User6670
    Commented Feb 12, 2020 at 21:00

1 Answer 1



    <aura:attribute name="options1" type="List" default="['1','2','3']"/>
    <aura:attribute name="options" type="List" default="[{'label': '', 'value': 'option1'}]"/>
    <aura:attribute name="value" type="String" default="option1"/>
 <aura:iteration items="{!v.options1}" var="organization">
     <input type="radio" id="{!organization}" name="options"  onclick="{!c.checkboxSelect}"  />

and in js

checkboxSelect: function(component, event, helper) {
   var selectedaccId= document.querySelector('input[name="options"]:checked').id;

  • Thanks @User6670, I just tried as you advised and got the following: This page has an error. You might just need to refresh it. Action failed: c:mycomponent$controller$selectAccountRadioGroupOnChange [event.getSource is not a function] Failing descriptor: {c:mycomponent$controller$selectAccountRadioGroupOnChange} Commented Feb 12, 2020 at 21:09
  • did you pass the event?
    – User6670
    Commented Feb 12, 2020 at 21:12
  • Also, can I even assign radioButtonGroup with value="{!organization.sourceId}"? Is there another way to store this bit of data per Iteration? Commented Feb 12, 2020 at 21:18
  • yes, I passed the event Commented Feb 12, 2020 at 21:25
  • selectAccountRadioGroupOnChange : function(component, event, helper) { helper.setAccountId(component, event, helper); } Commented Feb 12, 2020 at 21:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .