I want to fetch records using Aura component but I get the Invalid attribute "name" error in <aura:handler name="init" value="{!this}" action="{!c.myAction}" /> tag.


<aura:component controller="myClass" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global">

  <aura:attribute name="recordId" type="Id" />
  <aura:attribute name="previousPatJ" type="List" /> 

   <aura:handler name="init" value="{!this}" action="{!c.myAction}" />

   <aura:iteration  items="{!v.previousPatJ}" var="patj">
        Journey Name = {!patj.Name} <br/>



public class myClass{
    public static List<myObject> getPreviousJ(Id recordId){
        try {
            List<myObject> oldPatientJ = [SELECT Name FROM myObject 
                                          WHERE Previous_Journey__c = :recordId 

             return oldPatientJ;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());


myAction : function(component, event, helper) 
      var oldPatientJ = component.get("c.getPreviousJ");
         recordId: component.get("v.recordId")
      oldPatientJ.setCallback(this, function(data) 
         component.set("v.previousPatJ", data.getReturnValue());


Your Answer

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

Browse other questions tagged or ask your own question.