Skip to main content

I am using a table filter and model actions to update many models at once. The conditions that are being affected have a blank value and are off by default and all have the same name. I understand the snippet is updating the value and (as far as I can see) not declaring enabling/disabling the condition. 

The curious thing is when you change the option in the filter to a value all the models update correctly but when you set the filter back to “None” only one a set of models have the condition turned off, the other models have the condition on and the value is set to “blank”.

Models Update properly:


skuid.$M('ClassConsult'),<br> skuid.$M('EDUMarketing'),<br> skuid.$M('OnlineTraining'),<br> skuid.$M('FreeTraining'),<br> skuid.$M('TrainingInstitutionalClients'),<br> skuid.$M('TrainingRentalHouse'),<br> skuid.$M('TrainingVendorProvider'),<br> skuid.$M('TrainingAspiringCreative'),<br> skuid.$M('TrainingEstablishedProfessional') skuid.$M('AffiliateClass'),

Models Update but condition doesn’t turn off:


skuid.$M('IntegrationNoLabor'),<br> skuid.$M('RetailSales'),<br> skuid.$M('OnlineSales'),<br> skuid.$M('Distribution'),<br> skuid.$M('SalesShipping'),<br> skuid.$M('SalesInstitutionalClients'),<br> skuid.$M('SalesRentalHouse'),<br> skuid.$M('SalesVendorProvider'),<br> skuid.$M('SalesEstablishedProfessional'),<br> skuid.$M('SalesAspiringCreative'),<br> skuid.$M('StandardRental'),<br> skuid.$M('ShippingRental'),<br> skuid.$M('RentalInstitutionalClients'),<br> skuid.$M('RentalRentalHouse'),<br> skuid.$M('RentalVendorProvider'),<br> skuid.$M('RentalEstablishedProfessional'),<br> skuid.$M('RentalAspiringCreative'), skuid.$M('AccountSales'),


I checked the conditions on each model and they are all set up exactly the same.  I am not sure where else to investigate.


Full Snippet:


var $ = skuid.$; var officeValue = skuid.$M('OfficeFilters').getConditionByName('OfficeFilter').value; var targetModels = g]; targetModels.push( skuid.$M('IntegrationNoLabor'), skuid.$M('AccountSales'), skuid.$M('RetailSales'), skuid.$M('OnlineSales'), skuid.$M('Distribution'), skuid.$M('SalesShipping'), skuid.$M('SalesInstitutionalClients'), skuid.$M('SalesRentalHouse'), skuid.$M('SalesVendorProvider'), skuid.$M('SalesEstablishedProfessional'), skuid.$M('SalesAspiringCreative'), skuid.$M('StandardRental'), skuid.$M('ShippingRental'), skuid.$M('RentalInstitutionalClients'), skuid.$M('RentalRentalHouse'), skuid.$M('RentalVendorProvider'), skuid.$M('RentalEstablishedProfessional'), skuid.$M('RentalAspiringCreative'), skuid.$M('ClassConsult'), skuid.$M('AffiliateClass'), skuid.$M('EDUMarketing'), skuid.$M('OnlineTraining'), skuid.$M('FreeTraining'), skuid.$M('TrainingInstitutionalClients'), skuid.$M('TrainingRentalHouse'), skuid.$M('TrainingVendorProvider'), skuid.$M('TrainingAspiringCreative'), skuid.$M('TrainingEstablishedProfessional')); $.each(targetModels, function(){ this.setCondition(this.getConditionByName('OfficeFilter'), officeValue); });<br>

Tami,

You should probably use a conditional statement to determine if your source condition is active.

Update the beginning with this:


<br>var officeCondition = skuid.$M('OfficeFilters').getConditionByName('OfficeFilter'),<br>&nbsp; &nbsp; officeValue = officeCondition.value;


And update the end to this:


if (officeCondition.inactive) { //If the condition is inactive, deactivate all others.<br> $.each(targetModels, function(){<br> this.deactivateCondition(this.getConditionByName('OfficeFilter'));<br>&nbsp; });<br>} else { //The condition is active. Activate and Set the values of all the others.<br> $.each(targetModels, function(){<br> this.setCondition(this.getConditionByName('OfficeFilter'), officeValue);<br>&nbsp; });<br>}

Matt,

Perfect! Thank you so much.