I am using javascript as a form of validation to prevent certain combinations of fields to be saved. I know I should be using regular SalesForce validation to handle this, but according to the admins around here it would be too complex (Roll-ups on Counts on Formulas…). It works great on the creation of the object because I catch it before the save. I figured I could re-use the same snippet and have it run as an action every time the model is saved. What seems to be happening is that my logic runs and raises the error message, but the save still goes through. This is probably by design (I’m not saying that this behavior is wrong), I just would like to know if there is a way I can stop the save from happening. I tried returning false but that doesn’t seem to help. Here is my code just for kicks:
var params = arguments[0], $ = skuid.$;<br>var commodityName = skuid.$M('Opportunity').getFirstRow().Commodity__r.Name;<br>var countOfRateReadyLDC = 0;<br>$.each(skuid.$M('IntakeQueues').data, function(i,rowIQ){<br> countOfRateReadyLDC += rowIQ.LDC__r.LDC_LDC__c;<br>});<br>var hasLBMP = false;<br>var hasSingleBill = false;<br>$.each(skuid.$M('Tenors').data, function(j,rowTenor){<br> if(rowTenor.Pricing_Product__r.Name === 'LBMP+') hasLBMP = true;<br> if(rowTenor.Bill_Type__c === 'Single Bill') hasSingleBill = true;<br>});<br>if(hasLBMP && hasSingleBill && (countOfRateReadyLDC > 0) && (commodityName === 'Electricity')){<br> var pageTitle = $('#MyPageTitle');<br> var editor = pageTitle.data('object').editor;<br> editor.handleMessages([{message:'Sorry! Electric, Indexed, Single Bill deals are not allowed when an LDC is Rate Ready.', severity:'ERROR'}]);<br> return false;<br>}else{<br> return true;<br>}
