You need to sign in to do that
Don't have an account?
Greg Finzer
How do I get the current Account on a lightning component?
I just started using lightning today. Sorry for the simple question. I am creating a lightning component where I need to display some fields from the Account on the lightning page and then pass the Account.Id to a controller to get some calculated data.
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
What goes here?
<span>{!v.Name}</span>
</aura:component>
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
What goes here?
<span>{!v.Name}</span>
</aura:component>
Thanks,
Govindaraj.S
All Answers
Thanks,
Govindaraj.S
Thank you so much for your help. The problem that I had was that I did not understand that you had to specifically reference the recordId. I had it named accountId and it could not find it. I was doing accountId : component.get("v.accountId") instead of component.get("v.recordId")
This is the final for the helper:
({
loadAccount : function(component) {
var action = component.get("c.loadAccount");
action.setParams({
accountId : component.get("v.recordId")
});
action.setCallback(this, function(a) {
if (a.getState() === "SUCCESS") {
component.set("v.account", a.getReturnValue());
} else if (a.getState() === "ERROR") {
$A.log("Errors", a.getError());
}
});
$A.enqueueAction(action);
}
})
Thanks,
Greg