0

This page has an error. You might just need to refresh it. Unable to find action 'getAccountRecord' on the controller of c:ar2 Failing descriptor: {c:ar2}

public class ar2class {
@AuraEnabled
    public static List<Assets_Resources__c> getAssetRecord(){
        return new List<Assets_Resources__c> ([Select Name, Type_Of_Asset__c from Assets_Resources__c ]);
    }
}

<aura:component controller = "ar2class" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action = "{!c.doinit}" />
    <aura:attribute name="arlist" type="Assets_Resources__c[]" />
    <article class="slds-card">
      <div class="slds-card__header slds-grid">
        <header class="slds-media slds-media_center slds-has-flexi-truncate">
          <div class="slds-media__figure">
            <span class="slds-icon_container slds-icon-standard-account" title="description of icon when needed">
                <lightning:icon iconName="standard:account" size="large" alternativeText="List account"/>
            </span>
          </div>
            <div class="slds-media__body">
            <h2>
              <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Asset and Resources">
                <span class="slds-text-heading_small">Asset and Resources</span>
              </a>
            </h2>
          </div>
        </header>
       </div>
        <div class="slds-card__body">
        <table class="slds-table slds-table_bordered slds-no-row-hover slds-table_cell-buffer">
            <thead>
            <tr class="slds-text-title_caps">
              <th scope="col">
                <div class="slds-truncate" title="Name">Name</div>
              </th>
              <th scope="col">
                <div class="slds-truncate" title="Type">Type of asset</div>
              </th>
              
            </tr>
          </thead>
            <tbody>
              <aura:iteration items="{!v.arlist}" var="ar"> <!-- iteration account record.-->
                  <tr class="slds-hint-parent">
                      <th scope="row">
                          <div class="slds-truncate" title="Adam Choi"><a href="javascript:void(0);">{!ar.Name}</a></div>
                      </th>
                      <td>
                          <div class="slds-truncate" title="Company One">{!ar.Type}</div>
                      </td>
                      
                  </tr>                     
              </aura:iteration>
          </tbody>
            </table>
      </div>
      <footer class="slds-card__footer"><a href="javascript:void(0);"><!--View All <span class="slds-assistive-text">entity type</span>--></a></footer>
    </article>
</aura:component>

({
    doinit : function(component, event, helper) {
        helper.getAccontRecord(component);
    }
})

({
    getAccontRecord : function(component) {
        var action = component.get("c.getAccountRecord");
    action.setCallback(this, function(response) {
            var state = response.getState(); //Checking response status
            var result = JSON.stringify(response.getReturnValue());
            if (component.isValid() && state === "SUCCESS")
                component.set("v.arlist", response.getReturnValue());  // Adding values in Aura attribute variable.   
        });
        $A.enqueueAction(action);
                }
})
1

You named the method getAssetRecord, so that's what you should be calling, as in component.get("c.getAssetRecord").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.