Button to run all mass actions on tab?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a tab with about 6 tables, all with the same mass action. I'd like to create a button that would run the mass action for the selected rows on all the tables.

I could write the javascript to perform the action for each table, but thought it would be much easier to say "get this table, run this mass action."
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Looks like it was easier than I thought to get all the selected rows from all the tables on a page with javascript.

I'm sure this could be written more elegantly, but here's my code, if anyone's in a similar situation. this code assumes that all the tables you want to get selections from have the CSS class MyTables.

It also adds the selected records to a new model, preventing duplicates.

'addAll2PRL': function(){	
var $ = skuid.$; //Get all selected referrals
var selectedElements = $('.nx-skootable.MyTables').map(function(){
return $(this).data('object').list.getSelectedItems();
});
//Get exisitng PRL referrals var model = skuid.$M('PatientCaseReferral');
var existingReferrals = [];
$.each(model.getRows(),function(){
existingReferrals.push(model.getFieldValue(this,'Referral_Id__c'));
});//If selected referral is not currently in PRL, add it.
$.each(selectedElements,function(){
if (existingReferrals.indexOf(this.row.Id) == -1) {
model.createRow({additionalConditions:[{field:'Referral_Id__c', value: this.row.Id}]});
}
});
}
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Cool.  I love it when you guys answer your own questions!