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 

Dynamic ids not getting created in lightning component

Hi Need quck help if possible, 

Created below modal and tried to iterate a list and created dynamic ids on the modal components, but after pressing button on modal , the find function on lightning controller always says "undefined" value for dynamic ids are just created on modal , I can see other values in modal getting iterated perfectly. 

Modal Code------------------------------------------------------------------>

<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                                <aura:iteration items="{!v.fileToBeUploaded}" var="fileDetails">
                                    <lightning:input aura:id="{!'fileName------'+fileDetails.documentId}" value="{!}" required="true" name="input1" label="Confirm the file name" ></lightning:input>
                                    <lightning:select aura:id="{!'fileAttach-----'+fileDetails.documentId}" name="a_opt" label="Podklady Typ">
                                        <aura:iteration items="{!v.podklady}" var="pdkL">
                                            <option value="{!pdkL.idVal}">{!pdkL.idVal}</option>
                            <footer class="slds-modal__footer">
                                <lightning:button variant="neutral"
                                                  onclick="{! c.closeModel }"/>
                                <lightning:button variant="brand"

Lightning Js controller code -------------------------------------------------->
var uploadedFiles = component.get("v.fileToBeUploaded");
for(var i=0; i< uploadedFiles.length; i++){
Deepali KulshresthaDeepali Kulshrestha
Hi Abhishek,

I went through the query of yours and found aura: id doesn’t support expressions. You can only assign literal string values to aura: id. The alternative to this is to dynamically create the component using $A.createComponent and since the attribute is accessible via the JavaScript one can assign dynamic values to aura: Id Currently the expression syntax is not supported in the aura: id attribute.

Please refer to the following links as they might be helpful in solving your query:

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

Thanks and Regards,
Deepali Kulshrestha.
Sai Sasidhar BhagavathulaSai Sasidhar Bhagavathula
Can't we fetch the id dynamically from component ? Could you please assist on the same as I need to go with the above approach rather using Create Component methodology.

Thanks in Advance!