You need to sign in to do that
Don't have an account?
Rick Rossi
Lightning Component Error Question
Hello,
I am getting the same error on my custom lightning component, which is a custom component for account hierarchy. Any help would be great:
Message:Action failed: c:AccountHierarchy$controller$init [helper.checkForParent is not a function]
This is where the error occurs in my helper:
{
checkForParent : function(component, event, helper) {
var action = component.get("c.hasParent");
var acctId = component.get('v.recordId');
action.setParams({"accountId": acctId});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
component.set("v.hasParent", result);
}
});
$A.enqueueAction(action);
},
checkForChildren : function(component, event, helper) {
var action = component.get("c.numChildren");
var acctId = component.get('v.recordId');
action.setParams({"accountId": acctId});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
component.set("v.numChildren", result);
if(result == 1) {
component.set("v.childOrChildren", "child");
} else {
component.set("v.childOrChildren", "children");
}
}
});
$A.enqueueAction(action);
}
})
I am getting the same error on my custom lightning component, which is a custom component for account hierarchy. Any help would be great:
Message:Action failed: c:AccountHierarchy$controller$init [helper.checkForParent is not a function]
This is where the error occurs in my helper:
{
checkForParent : function(component, event, helper) {
var action = component.get("c.hasParent");
var acctId = component.get('v.recordId');
action.setParams({"accountId": acctId});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
component.set("v.hasParent", result);
}
});
$A.enqueueAction(action);
},
checkForChildren : function(component, event, helper) {
var action = component.get("c.numChildren");
var acctId = component.get('v.recordId');
action.setParams({"accountId": acctId});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
component.set("v.numChildren", result);
if(result == 1) {
component.set("v.childOrChildren", "child");
} else {
component.set("v.childOrChildren", "children");
}
}
});
$A.enqueueAction(action);
}
})
This code is fine. Maybe you are getting this error in the aura component or aura controller. So can you send me the code of the aura component and aura controller?
Thanks.
Thanks for the response! This is what I have so far:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
<div class="slds-section slds-is-open">
<h3 class="slds-section__title">
<button aria-controls="expando-unique-id" aria-expanded="true" class="slds-button slds-section__title-action">
<lightning:icon iconName="utility:switch" alternativeText="" size="x-small" />
<span class="slds-truncate" title="Section Title"> Account Hierarchy Link</span>
</button>
</h3>
<div aria-hidden="false" class="slds-section__content" id="expando-unique-id">
<a onclick="{!c.navigateToAccountHierarchy}">View Account Hierarchy</a>
</div>
</div>
</aura:component>
({
navigateToAccountHierarchy: function(cmp, event, helper) {
var acctId = cmp.get('v.recordId');
var evt = $A.get("e.force:navigateToComponent");
evt.setParams({
componentDef: "sfa:hierarchyFullView",
componentAttributes: {
recordId: acctId,
sObjectName: "Account"
}
});
evt.fire();
}
})