+ Start a Discussion
Michael CovertMichael Covert 

Need help with a Lightning Component Error!


I'm currently getting an error from one of my Lightning Components, it works completely as intended but under certain situations it will show this error and I can't seem to figure out how to fix it, to start I'll explain my component a litte.

The component lists all the Opportunities that the user is the Responsible Party on (Responsible Party is a lookup field on the opportunity) and it will refresh with every 5 minutes. This works perfectly.... But it will throw an error if the user switches pages and then goes back to the Responsible Party Component, it will throw the error on the next refresh. I also noticed after leaving that component it will continue to run thr refresh too. Any help would be greatly appreciated, I will show my code below and some of the steps I tried to resolve this issue.

  • Message: Uncaught Error in $A.getCallback() [Cannot read property 'setCallback' of undefined]
  • Function: Object.getOpps
  • Stack Trace:
    • Object.getOpps()@components/c/ResponsiblePartyList.js:19:15
    • Object.<anonymous>()@components/c/ResponsiblePartyList.js:28:18
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="ResponsiblePartyListApexController">
    <aura:attribute name="refreshTimer" type="Integer" default="2" access="global" />
    <aura:attribute name="records" type="Opportunity[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <Lightning:card title="Opportunities" iconName="standard:opportunity">
        <table class="slds-table slds-table_bordered slds-table_cell-buffer">
                <tr class="slds-text-title_caps">
                    <th scope="col"><div class="slds-truncate" title="Borrower Name" >Borrower Name</div></th>
                    <th scope="col"><div class="slds-truncate" title="Stage" >Stage</div></th>
                    <th scope="col"><div class="slds-truncate" title="Loan Officer" >Loan Officer</div></th>
                    <th scope="col"><div class="slds-truncate" title="Last Modified" >Last Modified</div></th>
                    <th scope="col"><div class="slds-truncate" title="Created" >Created</div></th>
                <aura:iteration items="{!v.records}" var="record" >
                        <th scope="row" data-label="Borrower Name">
                            <div class="slds-truncate" title="{!record.Borrower_Name__r.LastName + ', ' + record.Borrower_Name__r.FirstName}"><a href="{!'/one/one.app#/sObject/' + record.Id + '/view'}">{!record.Borrower_Name__r.LastName + ', ' + record.Borrower_Name__r.FirstName}</a></div>
                        <td data-label="Stage">
                            <div class="slds-truncate" title="{!record.StageName}">{!record.StageName}</div>
                        <td data-label="Loan Officer">
                            <div class="slds-truncate" title="{!record.Loan_Officer__r.FirstName + ' ' + record.Loan_Officer__r.LastName}">{!record.Loan_Officer__r.FirstName + ' ' + record.Loan_Officer__r.LastName}</div>
                        <td data-label="Last Modified">
                            <ui:outputDate value="{!record.LastModifiedDate}" />
                        <td data-label="Created">
                            <ui:outputDate value="{!record.CreatedDate}" />
	doInit : function(component, event, helper) {
	getOpps : function(component) {
        var refreshTimer = component.get("v.refreshTimer");
        var refresh = (refreshTimer * 60) * 1000;
        var that = this;
        var action = component.get("c.getOppsDB");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.records", response..getReturnValue());
            window.setTimeout($A.getCallback(function() {
        	}), refresh

I have tried to add an  action.setAbortable(), that did nothing to change it. I also tried adding isValid to the component to ensure it wasn't destroyed. I'm not sure what else I can do to fix the error but still have the auto refesh option, any information would help!

Michael Covert