<aura:iteration items="{!v.userCustomFieldSet}" var="fieldSet" indexVar="i"> <ui:inputText value="{!fieldSet.FieldValue}" aura:id="{!fieldSet.FieldName}"/> </aura:iteration>

Above code, Getting Error when i'm accessing the field-set Cannot read property 'getElement' of undefined

  • You cannot assign auraid’s dynamically
    – glls
    Commented Jul 23, 2018 at 12:15
  • I think that here you can find solution of your problem. Commented Jul 23, 2018 at 12:17

2 Answers 2


Like glls pointed out, dynamic aura:ids are not supported (yet). It will be helpful to know what your end goal is so we can make an effective recommendation. Did you know that if you set the aura:id to a static value like: aura:id="myInput", you can get the values in ControllerJS by doing: component.find("myInput").get("v.value")? That will work as long as there is precisely ONE matching aura:id in the component. But in your case there will be multiple because of aura:iteration, so component.find("myInput") will return an array of all matching elements you can easily loop through.


As mentioned in by @glls in the comment and @Kal answer - You cannot assign auraid’s dynamically, instead you can use the element's id via document.getElementById:

<aura:iteration items="{!v.userCustomFieldSet}" var="fieldSet" indexVar="i"> 
     <ui:inputText value="{!fieldSet.FieldValue}" id="{!fieldSet.FieldName}"/> 

and in you controller get the element like this:

var fieldName = document.getElementById('fieldName');

I got help on this from an answer that @sfdcfox gave me here:

component.find an aura:id item created in aura:iteration

You must log in to answer this question.

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