2

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

  • "I was playing arround with my javascript Controller code and randomly this happened" --> things don't happen randomly when you start messing around in code, and the error message is providing a pretty good clue of what and where to check. do you have access to the controller code? it would be a good place to check as well or could give you a better idea of what is missing that throws this error – glls Jun 11 '18 at 23:24
  • My bad, I posted this elsewhere, but I re-referenced old code and there's no difference. The error message points to the internal aura framework logic which is obfuscated and almost impossible to debug. Yes, I have access to controller logic, but I don't see why it would be a controller error as the error popup itself shows a javascript runtime error. – Sairisheek Muttukuru Jun 11 '18 at 23:35
  • well, once you figure out where "Cannot read property 'config' of undefined" is coming from, feel free to update your post – glls Jun 12 '18 at 1:07
  • @glls That's the problem, I can't. The error message comes from an internal function and I don't have the resources to debug it. – Sairisheek Muttukuru Jun 12 '18 at 2:35
  • 1
    This sounds silly, but I had a lightning:spinner without an alternativeText param on my Component. I got a warning in the console asking to add the alternativeText. I fixed the issue, and the [Cannot read property 'config' of undefined] went away – Scott Pelak Jul 26 '18 at 14:37
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.