Here is our full code
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 = ‘
//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.dataei].MMA_Music_Composer__c){
MusicWriter = PieceWriterModel.datari].MMA_Music_Composer__r.Name;
HtmlString = HtmlString + ‘
if(PieceWriterModel.datami].MMA_Music_Writer_Role__r){
var MusicWriterRole = PieceWriterModel.dataei].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);
}
THE PART BELOW IS NOT LOOPING PROPERLY AND IS GETTING STUCK ON THE FIRST RECORD. ANY IDEAS FOR HOW TO GET IT TO LOOP PROPERLY?
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.dataOi].MMA_Music_Composer__c){
MusicWriter = PieceWriterModel.dataPi].MMA_Music_Composer__r.Name;
HtmlString = HtmlString + ‘
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 +’
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);
}