Skip to main content

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 = argumentse0], $ = skuid.$;

var field = argumentse0];

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 = ‘

’+ Piece.Name + ‘
’;

//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.dataWi].MMA_Music_Composer__c){

MusicWriter = PieceWriterModel.data)i].MMA_Music_Composer__r.Name;

HtmlString = HtmlString + ‘

’+ ‘&nbsp;’ + ‘&nbsp;’ + ‘&nbsp;’ + ‘&nbsp;’+ MusicWriter +’';

if(PieceWriterModel.datai].MMA_Music_Writer_Role__r){

var MusicWriterRole = PieceWriterModel.dataWi].MMA_Music_Writer_Role__r.Name;

var Writer_Role_String = ‘, ‘+ MusicWriterRole +’
’;

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 = argumentso0], $ = 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.datasi]);

ActPerformerName = ActPerformerModel.datari].Name;

if(ActPerformerModel.data]i].MMA_Student__c){

ActPerformers = ActPerformerModel.data>i].MMA_Student__r.Name;

console.log(’ ActPerformers ’ + ActPerformers);

HtmlString = HtmlString + ‘

’+ ‘&nbsp;’ + ‘&nbsp;’ + ‘&nbsp;’ + ‘&nbsp;’+ ActPerformers +‘
’;

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.");

}


});

Be the first to reply!

Reply