Uncaught TypeError: Cannot read property 'tid' of undefined

  • 1
  • Problem
  • Updated 3 years ago
  • In Progress
I have a field editors with one custom snippet each. When I run the two pieces of code separately, they both load. When I run them together, I sometimes get this error:

***Uncaught TypeError: Cannot read property 'tid' of undefined***

Here are the two pieces of code:

PieceName
var params = arguments[0], $ = skuid.$;
var field = arguments[0];
var model = field.model;
var row = field.row;
var HtmlString = '';
var ActName = row.Name;
var Piece = row.Piece__r;
    if(Piece){
        console.log(Piece.Name);
        //var PieceWriterModel = skuid.model.getModel("MMA_Music_Piece_Writer");
        //var MusicPieceCondition = PieceWriterModel.getConditionByName("MMA_Music_PieceId");
        //var PieceId = Piece.Id;
        var Piece_Name = Piece.Name;
        HtmlString = '<div><ul><strong><font size="3" style="font-family:Georgia">'+ Piece.Name + '</strong></ul></div>';
        //var cellElem = field.element;
        //console.log(HtmlString);
        //cellElem.html(HtmlString);
        }
    else{
        HtmlString = ActName + '';
        window.alert(ActName + ' - There is no peice in thie Act.')
        //cellElm = field.element;
        }
        
var NoOfWriters = 0;
var MusicWriter ='none';
    if(Piece){
        var PieceWriterModel = skuid.model.getModel("MMA_Music_Piece_Writer");
        var MusicPieceCondition = PieceWriterModel.getConditionByName("MMA_Music_PieceId");
        var PieceId = Piece.Id;
        PieceWriterModel.setCondition(MusicPieceCondition,PieceId);
        console.log('After Set condition' + PieceId + ' PieceId ');
        PieceWriterModel.updateData(function(){
            NoOfWriters = PieceWriterModel.data.length;
            if(NoOfWriters>0){
                for(i=0;i<NoOfWriters;i++){
                    if(PieceWriterModel.data[i].MMA_Music_Composer__c){
                    MusicWriter = PieceWriterModel.data[i].MMA_Music_Composer__r.Name;
                    HtmlString = HtmlString + '<div><ul><em><font color="grey" size="3" style="font-family:Georgia">'+ '&nbsp;' + '&nbsp;' + '&nbsp;' + '&nbsp;'+ MusicWriter +'';
                    if(PieceWriterModel.data[i].MMA_Music_Writer_Role__r){
                        var MusicWriterRole = PieceWriterModel.data[i].MMA_Music_Writer_Role__r.Name;
                        var Writer_Role_String = ', '+ MusicWriterRole +'</em></ul></div>';
                        HtmlString = HtmlString + Writer_Role_String;
                        
                        }
                    else{
                        }}
                        else{
                            window.alert(Piece_Name + ' - This Piece does not have any associated Music Writers.');
                        }
                }
                var cellElem = field.element;
                cellElem.html(HtmlString);
            }
        });
       
    
        
    }
    else{
        cell.Elem.html(HtmlString);
    }


ActPerformersNames
var params = arguments[0], $ = skuid.$;
var field = arguments[0];
var model = field.model;
var row = field.row;
console.log(row);
var ActId = row.Id;
console.log(ActId + ' ActId ');
var NoOfActPerformers = 0;
var ActPerformers ='none';
var HtmlString = '';
var Piece = row.Piece__r.Name;
var ActPerformerModel = skuid.model.getModel("MMA_Academy_Student_Event_Act_Performer");
var Condition = ActPerformerModel.getConditionByName('ConditionForSpecificAct');
var ActPerformerName = '';
ActPerformerModel.setCondition(Condition,ActId);
ActPerformerModel.updateData(function(){
    var NoOfActPerformers = ActPerformerModel.data.length;
    console.log(NoOfActPerformers);
        if(NoOfActPerformers>0){
                for(i=0;i<NoOfActPerformers;i++){
                    console.log(ActPerformerModel.data[i]);
                    ActPerformerName = ActPerformerModel.data[i].Name;
                    if(ActPerformerModel.data[i].MMA_Student__c){
                        ActPerformers = ActPerformerModel.data[i].MMA_Student__r.Name;
                        console.log(' ActPerformers ' + ActPerformers);
                        HtmlString = HtmlString + '<div align="right"><ul><em><font color=#4F4F4F size="3" style="font-family:Georgia">'+ '&nbsp;' + '&nbsp;' + '&nbsp;' + '&nbsp;'+ ActPerformers +'</em></ul></div>';
                        var cellElem = field.element;
                        cellElem.html(HtmlString);
                    }
                    else{
                        window.alert(ActPerformerName + ' - This Act Performer is not attached to a Student Record.');
                    }
                }}
                else{
                    window.alert(Piece + " - This Act has no performers attached to it.");
                }
        
        
});  
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
  • frustrated

Posted 3 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
I notice you have console.log() in both snippets.  What does the trace look like when you run with dev tools opened?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Anna.  With another customer we have seen that this error is shown when a javascript remoting call fails because the request size is more than a million bytes.  With this other customer we realized that there was a skuid problem that was doubling the http traffic.  We have fixed this issue and it will be released in the next few days.  So my first reccomendation would be to wait for the new package and see if that corrects matters.  If it doesn't we'd like to dig in a little deeper and see what is going on.   

Fair?

I'll ping you directly when the new package is availalbe. And we'll dig further if it doesn't get fixed. 
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
Sounds Great. Thanks!