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
Mark Moser 10Mark Moser 10 

how do i use component.find for an aura:id in an aura:iteration and then inside an aura:if

Component:

 <aura:iteration items="{!v.fields}" var="f">
              <aura:if
                isTrue="{!((v.recordId==null&amp;&amp;f.fieldPath=='genesis__Business_Name__c'))}"
              >
                <aura:if
                  isTrue="{!and(not(v.newAccount), empty(v.tradeUpDetails))}"
                >
                  <lightning:inputField
                    fieldName="genesis__Account__c"
                    aura:id="inputFieldAccountName"
                    class="input-is-required"
                    onchange="{!c.lookupChange}"
                    value="{!v.accountId}"
                    autocomplete="nope"
                  />
                  <aura:set attribute="else">
                    <lightning:inputField
                      fieldName="genesis__Business_Name__c"
                      aura:id="inputFieldAccountId"
                      class="input-is-required"
                      autocomplete="nope2"
                    />
                  </aura:set>
                </aura:if>
              </aura:if>
              <aura:if

Helper:

 var inputAccountName = component.find("inputFieldAccountName");
 console.log(inputAccountName.get("v.value"));

gets exception on var input account name but just stops running at that point

 
David Zhu 🔥David Zhu 🔥
component.find("inputFieldAccountName"); returns an array of component in your case.
You may need to loop the array to get the value.
Mark Moser 10Mark Moser 10
I put this in the code: console.log('right before 1'); console.log(component.get("v.accountId")); var inputAccountName = component.find("inputFieldAccountName"); for(var i=0;i