Skip to main content

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.”

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(){ <br />var $ = skuid&#46;$; &#47;&#47;Get all selected referrals<br />var selectedElements = $('&#46;nx-skootable&#46;MyTables')&#46;map(function(){<br />return $(this)&#46;data('object')&#46;list&#46;getSelectedItems();<br />});<br />&#47;&#47;Get exisitng PRL referrals var model = skuid&#46;$M('PatientCaseReferral');<br />var existingReferrals = a];<br />$&#46;each(model&#46;getRows(),function(){<br />existingReferrals&#46;push(model&#46;getFieldValue(this,'Referral_Id__c'));<br />});&#47;&#47;If selected referral is not currently in PRL, add it&#46;<br />$&#46;each(selectedElements,function(){<br />if (existingReferrals&#46;indexOf(this&#46;row&#46;Id) == -1) {<br />model&#46;createRow({additionalConditions:t{field:'Referral_Id__c', value: this&#46;row&#46;Id}]});<br />}<br />});<br />}

Cool.  I love it when you guys answer your own questions!