Cannot read property ‘config’ of undefined

I get this error just randomly:

Uncaught Error in $A.getCallback() [Cannot read property 'config' of undefined]
Callback failed: apex://taskKanbanController/ACTION$getKanbanWrap

Here’s the relevant controller code:

({
    doInit: function(component, event, helper) {

        console.log('doInit doInit doInit doInit!!!!!!!!! ' + component.getGlobalId());    
        var vfOrigin = "https://" + component.get("v.vfHost");

        window.addEventListener("message", function(event) {
               console.log("EVENT HERE!");
            console.dir(event);


            try{
                event.data.indexOf('s');
            }catch(err){
                return;
            }
            if(event.data.indexOf('isUnload') > -1  || event.data.indexOf('isLoaded') > -1){
                helper.hideSpinner(component);
                return;
            }
            if (event.origin !== vfOrigin || event.data.indexOf('FileUpload') > -1)
                return;

            if(event.data == 'Need Projects'){
                helper.ganttPstMsg(component, 'kanbanData',null);                
            }else if(event.data.indexOf('onTaskClick') == 0){
                var msg = (event.data).split('-');
                component.set("v.recordName",msg[2]);
                component.set("v.recordId",msg[1]);
                component.set("v.rViewFlag",true);
            }else if(event.data == 'Task order changed update data on root component'){
                helper.doInitHelp(component,helper, false);
            }else if(event.data.indexOf('newTaskAdd') == 0){
                var msg = (event.data).split('-');
                component.set('v.recordId',msg[1]);
                $('.newTaskBBB').click();
            }

        }, false);


          helper.doInitHelp(component,helper, false);
        document.addEventListener("DOMContentLoaded", function(event) { 
              setTimeout(helper.alignProjs(),1000);
            });



    },

And here’s the relevant helper code, where execution fails:

doInitHelp : function(component, helper, viewChange) {
        console.log('doInitHelp');
        var prjLst = [];
        var resLst = [];




        console.log('firstLoad>>>>>>>>>>  '+ component.get('v.firstLoad'));
        if(!component.get('v.firstLoad')){
            var checkboxes = component.find('prjCheckbox');
            if(checkboxes)
            if(Array.isArray(checkboxes)){
                for (var i = 0; i < checkboxes.length; i++){
                    if(checkboxes[i].get("v.checked"))
                        prjLst.push(checkboxes[i].get("v.name"));
                }
            }else{
                if(checkboxes.get("v.checked"))
                    prjLst.push(checkboxes.get("v.name"));
            }
            var rcheckboxes = component.find('userCheckbox');
            if(rcheckboxes)
            if(Array.isArray(rcheckboxes)){
                for (var i = 0; i < rcheckboxes.length; i++){
                    if(rcheckboxes[i].get("v.checked"))
                        resLst.push(rcheckboxes[i].get("v.name"));
                }
            }else{
                if(rcheckboxes.get("v.checked"))
                    resLst.push(rcheckboxes.get("v.name"));
            }
            if(component.get('v.menuItem') == 'Searched'){
                prjLst = [];
                prjLst.push(component.get("v.searchPrj").Project__c);
            }
            console.log('SearchedSearchedSearchedSearched::   ' + component.get("v.searchPrj").Project__c);
        }

        console.dir(prjLst);
        var action = component.get("c.getKanbanWrap");
        action.setStorable();
        action.setParams({
            "menuItem":component.get('v.menuItem'),
            "prjs":prjLst.toString(),
            "ress":resLst.toString(),
            "firstLoad":component.get('v.firstLoad')
        });

        action.setCallback(this, function(response){
            helper.handleResponse(component, helper, viewChange, response, null);
        });
        $A.enqueueAction(action);

    },
    handleResponse : function(component, helper, viewChange, response, recId) {
        console.log('HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH');
        var state = response.getState();
            if (state === "SUCCESS") {

                console.dir(response.getReturnValue());
                //console.log(JSON.stringify(response.getReturnValue()));

                var kd = response.getReturnValue();
                if(kd.userTmSetting.Current_Tab__c == 'kanban'){
                    var list = kd.lst;
                    for (var i = list.length - 1; i >= 0; i--) {
                        list[i]['sIdx']=list[i].lstSize > 0 ? 0 : list[i].lstSize - 1;
                        list[i]['eIdx']=list[i].lstSize > 25 ? 25 : list[i].lstSize;
                    }    
                }


                console.dir("DEBUG1")
                console.dir(component.get("v.kanbanData"))
                >>component.set("v.kanbanData", kd);<<
                console.dir("DEBUG2");
                component.set("v.viewComponent", kd.userTmSetting.Current_Tab__c);
                console.dir("DEBUG3");
                component.set('v.menuItem',kd.userTmSetting.Current_Menu_Item__c);
               console.dir("DEBUG4");

Execution fails exactly at the marked (“>> <<“) portion and I have no clue why. kd is not null

Answer

My case was quite similar:
I had lightning:input with aura:id attribute and onclick action which triggered action and got same issue.

After removing aura:id attribute problem solved

Attribution
Source : Link , Question Author : Sairisheek Muttukuru , Answer Author : Jackson Chen

Leave a Comment