Uncaught TypeError: object is not a function

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I have a JS mass action that works great, I call updateData() inside of a save callback. If I leave the updateData() as is, it works fine. However if I change updateData() into a callback, i get an error that: Uncaught TypeError: object is not a function. here's my code:

var params = arguments[0];var $ = skuid.$;
var records = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ 
return item.row.Id; 
}); 
var EDIHistory = params.model;
//notify user of progress
$.blockUI({
message:'Resubmitting'
});

for (var n in records) {
var row = EDIHistory.getRowById(records[n]);
EDIHistory.updateRow(row, 'Manually_Resubmit__c', 'true');
}
//save the model and wait for success
EDIHistory.save({callback:function(result){

if (result.totalsuccess){
// update the data
            EDIHistory.updateData({callback:function(result){
                if (result.totalsuccess){
                    $.unblockUI();
                }
            }});
}
else{
alert("Something went wrong!");
}
}});

Is there something wrong with the placement of the "$.umblockUI()"? What is the issue here?

Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb

Posted 4 years ago

  • 1
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 2,996 Points 2k badge 2x thumb
Hey Moshe,

The updateData function expects a function. You are currently passing in an object with a callback function defined. Try the following instead:

            EDIHistory.updateData(function(result){
                if (result.totalsuccess){
                    $.unblockUI();
                }
            });
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Hi Moshe, this is an unfortunate inconsistency in our API, that we hope to remedy at some point.  I think we would start out by supporting the syntax that you tried to use, but for now, you have to just send in a function like JD said.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Thanks Guys.