You need to sign in to do that
Don't have an account?
Dinesh Lodhi
Lightning issue--Uncaught Error in $A.getCallback() [system is not defined] Callback failed: apex://AccountPracticeLC/ACTION$FetchAccountRecord
Hello Everyone,
I am new to SF Lightning, getting above issue while retrieving 10 accouts record on Lightning Builder App.
Kindly assist to resolve this issue.
----AccountPracticeLC.apxc---------------------
public class AccountPracticeLC {
public static List<Account> ListAct;
@AuraEnabled
public static List<Account> FetchAccountRecord(){
ListAct = [select Name, AccountNumber, Phone, Industry from Account Limit 10];
return ListAct;
}
}
-------------AccountPracticeLC_Cmp.cmp-----------------
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller ="AccountPracticeLC" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="Accounts" type="Account[]"/>
<section class="slds-card__body">
<div class="slds-tile slds-hint-parent">
<p class="slds-tile__title slds-truncate">Name:
<ui:outputText value="{!v.Accounts.Name}"/>
</p>
<p class="slds-truncate">Account Number:
<ui:outputText value="{!v.Accounts.AccountNumber}"/>
</p>
<p class="slds-truncate">Phone:
<ui:outputNumber value="{!v.Accounts.Phone}" />
</p>
<p class="slds-truncate">Industry:
<ui:outputText value="{!v.Accounts.Industry}" />
</p>
</div>
</section>
</aura:component>
--------------------------Controller---------------
({
doInit : function(component, event, helper) {
helper.FetchAccountRecord(component);
},
})
-------------------------Helper--------------------
({
FetchAccountRecord: function(component) {
var action = component.get("c.FetchAccountRecord");
action.setCallback(this, function(data) {
var state = data.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.Accounts", data.getReturnValue());
system.log(response.getReturnValue());
}
});
$A.enqueueAction(action);
},
})
I am new to SF Lightning, getting above issue while retrieving 10 accouts record on Lightning Builder App.
Kindly assist to resolve this issue.
----AccountPracticeLC.apxc---------------------
public class AccountPracticeLC {
public static List<Account> ListAct;
@AuraEnabled
public static List<Account> FetchAccountRecord(){
ListAct = [select Name, AccountNumber, Phone, Industry from Account Limit 10];
return ListAct;
}
}
-------------AccountPracticeLC_Cmp.cmp-----------------
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller ="AccountPracticeLC" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="Accounts" type="Account[]"/>
<section class="slds-card__body">
<div class="slds-tile slds-hint-parent">
<p class="slds-tile__title slds-truncate">Name:
<ui:outputText value="{!v.Accounts.Name}"/>
</p>
<p class="slds-truncate">Account Number:
<ui:outputText value="{!v.Accounts.AccountNumber}"/>
</p>
<p class="slds-truncate">Phone:
<ui:outputNumber value="{!v.Accounts.Phone}" />
</p>
<p class="slds-truncate">Industry:
<ui:outputText value="{!v.Accounts.Industry}" />
</p>
</div>
</section>
</aura:component>
--------------------------Controller---------------
({
doInit : function(component, event, helper) {
helper.FetchAccountRecord(component);
},
})
-------------------------Helper--------------------
({
FetchAccountRecord: function(component) {
var action = component.get("c.FetchAccountRecord");
action.setCallback(this, function(data) {
var state = data.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.Accounts", data.getReturnValue());
system.log(response.getReturnValue());
}
});
$A.enqueueAction(action);
},
})
Two errors: reponse instead of data and system.log instead of console.log (it is javascript not apex)
system.log(response.getReturnValue());console.log(data.getReturnValue());
https://developer.mozilla.org/fr/docs/Web/API/Console/log
It lacks also <aura:iteration items="{!v.Accounts}" var="acc"> for the component. https://trailhead.salesforce.com/fr/projects/quickstart-lightning-components/steps/quickstart-lightning-components
Best regards
Alain
All Answers
Two errors: reponse instead of data and system.log instead of console.log (it is javascript not apex)
system.log(response.getReturnValue());console.log(data.getReturnValue());
https://developer.mozilla.org/fr/docs/Web/API/Console/log
It lacks also <aura:iteration items="{!v.Accounts}" var="acc"> for the component. https://trailhead.salesforce.com/fr/projects/quickstart-lightning-components/steps/quickstart-lightning-components
Best regards
Alain
It worked..
correct me if i am wrong.