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
Rahul r 56Rahul r 56 

Assertion Failed!



Lightning Component:

<aura:component controller="LC_Lst_Acnt_tile">
    <aura:attribute name="acco" type="Account[]"/>
     <aura:attribute name="Srchacc" type="string"/>
   
    <lightning:layout  multipleRows="True">
      <lightning:layoutItem size="4">
        <lightning:card title="Search Accounts">
           
            <aura:set attribute="actions">
               <lightning:button label="search" onClick="{!c.searchme}"/>
            </aura:set>
           
            <lightning:input label="Enter the Text" value="{!v.Srchacc}"/>
            </lightning:card>
          </lightning:layoutItem>
               
         <lightning:layout>
        <lightning:card title="Tile view">
             <aura:iteration items="{!v.acco}" var="sd"/>
            <lightning:layoutItem size="4">
                Name:{!sd.Name} <p/>
                Phone:{!sd.Phone}<p/>
                Fax:{!sd.Fax}<p/>
            </lightning:layoutItem>
           
          </lightning:card>
        </lightning:layout>
       
    </lightning:layout>
</aura:component>

-------------------------------------------------------------------------------------------------------

Controller:


({
searchme : function(component, event, helper) {
var aa= component.get("v.Srchacc");
        var action=component.get("c.TileAccount");
        action.setParams({"st":aa});
        action.setCallback(this,function(response){
           
            var state=response.getState();
            var res=response.getReturnvalue();
            component.set("v.acco",res);
        });
        $A.enqueueAction(action);
}
})


-------------------------------------------------------------------------------

Apex Class:



public class LC_Lst_Acnt_tile {

    @AuraEnabled
    public static List<Account> TileAccount(string st)
    {
        string query='select Name,Phone,Fax from Account where Name like \'%'+st+'%\'';
        List<Account> acc= Database.query(query);
        system.debug(acc);
        return acc;
    }
}


------------------------------------------------------------------------------------------

Lightning Application:

<aura:application extends="force.slds">
    <c:Lc_List_Account_tile/>
</aura:application>


--------------------------------------------------------------------------------------------


Error Message:



This page has an error. You might just need to refresh it.
Assertion Failed!: Unable to get value for key 'sd.Name'. No value provider was found for 'sd'. : false
Failing descriptor: {c:Lc_List_Account_tile}


-------------------------------------------------------------------------

Hi All,

Can any one correct me where iam Wrong
Rahul r 56Rahul r 56
Hi all,

i have got the answer 

in above program i have self closed the <aura:iteration>.this is why assertion failed now iam able to exute programe succesfully 

Thanks...........!!!!!!!!!
Dushyant SonwarDushyant Sonwar
1)aura:iteration should also have closing tag.
2) javascript is case sensitive language, so it needs to have exact case otherwise will throw error . 

response.getReturnvalue(); will be changed to response.getReturnValue();
<aura:component controller="LC_Lst_Acnt_tile">
    <aura:attribute name="acco" type="Account[]"/>
     <aura:attribute name="Srchacc" type="string"/>
   
    <lightning:layout  multipleRows="True">
      <lightning:layoutItem size="4">
        <lightning:card title="Search Accounts">
           
            <aura:set attribute="actions">
               <lightning:button label="search" onclick="{!c.searchme}"/>
            </aura:set>
           
            <lightning:input label="Enter the Text" value="{!v.Srchacc}"/>
            </lightning:card>
          </lightning:layoutItem>
               
         <lightning:layout>
        <lightning:card title="Tile view">
             <aura:iteration items="{!v.acco}" var="sd">
            <lightning:layoutItem size="4">
                Name:{!sd.Name} <p/>
                Phone:{!sd.Phone}<p/>
                Fax:{!sd.Fax}<p/>
            </lightning:layoutItem>
            </aura:iteration>
          </lightning:card>
        </lightning:layout>
       
    </lightning:layout>
</aura:component>
 
({
searchme : function(component, event, helper) {
var aa= component.get("v.Srchacc");
        var action=component.get("c.TileAccount");
        action.setParams({"st":aa});
        action.setCallback(this,function(response){
           
            var state=response.getState();
            var res=response.getReturnValue();            
            component.set("v.acco",res);
        });
        $A.enqueueAction(action);
}
})