0

like this

I wanted to try pass the object Name and thier related query by using design attribute and show the records on app page but I have no idea how to do this. please help me. and How I store the upcoming data in Lightning Datable ?

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
  <aura:attribute name="objectName" type="String" /> 
  <aura:attribute name="Query" type="String" />
  <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> 
  <lightning:card> test </lightning:card> 
</aura:component>

<design:component> 
  <design:attribute name="objectName" Label="Object Name"/> 
  <design:attribute name="Query" Label="Query"/>
</design:component>

1 Answer 1

1

You just need some Apex code to complete the project:

public class MyController {
  @AuraEnabled public static sObject[] getRecords(String query) {
    return Database.query(query);
  }
}

And in your component markup:

controller="MyController"

And in your doInit method:

doInit: function(component, event, helper) {
  let action = component.get("c.getRecords");
  let query = component.get("v.Query");
  action.setParams({ query });
  action.setCallback(this, function(response) { 
    // Handle response here
  });
  $A.enqueueAction(action);
},
1
  • Thank u for code and please help me. How I store the upcoming data in Lightning Datable ? Commented Dec 16, 2022 at 3:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .