Javascript error in custom field renderer

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
We need to access the "PieceWriterModel" after the condition has been applied. any attempt to read the data in a callback results in this error "f is not a function". Any ideas?

PieceWriterModel = skuid.model.getModel("MMA_Music_Piece_Writer");       
var MusicPieceCondition = PieceWriterModel.getConditionByName("MMA_Music_PieceId");
        var PieceId = row.Piece__r.Id;
        console.log(PieceId);
        PieceWriterModel.setCondition(MusicPieceCondition,PieceId);
        PieceWriterModel.updateData({callback:function(result){
            console.log(PieceWriterModel);
                }});
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Have you tried the jquery deferred syntax instead? It seems clearer to me:

skuid.$.when(PieceWriterModel.updateData()).then(function(){console.log(PieceWriterModel);});
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
var PieceWriterModel = skuid.model.getModel("MMA_Music_Piece_Writer");
var MusicPieceCondition = PieceWriterModel.getConditionByName("MMA_Music_PieceId");
var PieceId = row.Piece__r.Id;
console.log(PieceId);
PieceWriterModel.setCondition(MusicPieceCondition, PieceId);
$.when(PieceWriterModel.updateData())
    .done(function() {
        console.log('Success');
    })
    .fail(function() {
        console.log('Error');
    });
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
Thanks to you both! Matt, it worked.