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
john miirjohn miir 

how to get the account related quotes into an lightning component

I want to create a lightning component where i need to pass the current account Id to the component and display all the quotes that are related to the account id.
Best Answer chosen by john miir
    <aura:attribute name="recordId" type="string" />
    <aura:attribute name="data" type="[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue="{!data}">
JS Controller:
    doInit: function(component, event, helper) {
        var action = component.get("c.getQuotes");

            accountId: component.get("v.recordId")
        action.setCallback(this, function(response) {
            var state = response.getState();
            var t = JSON.parse(response.getReturnValue());
            component.set("", t);
APex Class:

    public with sharing class {
        public static List < Quotes > quotes(String accountId) {
            if (accountID != NULL)
                List < Quotes > q = [SELECT Id, Name FROM QUOTES WHERE Account =: AccountId]
            return (q);

Hope this gives an overall idea of how to Call Apex class from Component and retrieve value to display back on the UI leve. 


Skype: gaurav62990