function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
beener3beener3 

Validation Not Working

Hi All.

 

I am able to save records that fail the validation. this is not a question about validation rules, they are fine, this is a question about how the hell the user has managed to save such records, on a consistant basis.

 

Background:

 

  1. I have a custom object called Timesheet with some validation rules.
  2. I have a requirement to allow "manual override" mode. records in this mode have are exempt from the validation rule. 
    so I added a checkbox called  Inclusive_Rate_Validation_Override__c. The validation rules are programmed so that if this checkbox is turned on, the validation rules always allow the record to be saved.
  3. so far so good, if the box is clear, validation rules fire, if checked, the rules don't fire. great!

 

Plot thickens:

Users sometime click the box by mistake, So I've removed the checkbox from the layout, and created a detail page button to toggle the checkbox for them, after a confirmation dialog.

 

now here's the problem. I can now consistantly save objects that fail validation. by removing the override mode after changing the values. to clarify, here are the steps:

 

  1. Create the record with 'proper' values
  2. Click the button which checks the box. (I can now put non conforming values)
  3. change values so that they don't conform to validation , save
    (this is not a problem, as validation override is still checked)
  4. use the button to get out of validation mode. (this shouldn't save, as the values dont' conform)
  5. now I have objects with values that fail validation.
The detail page button code (below) is very very simple. I don't see a place for error. I just don't think that the validation is triggered in this update. this doesn't happen when toggeling via the interface.
 
Any ideas please?
 
Thanking you for your time.
 
Ben 

 

 

 

var question = "You are about to ";if ( {!Timesheet__c.Inclusive_Rate_Validation_Override__c}) question+= "DISABLE";else question+= "ENABLE";question+= " manual override for this timesheet.\nAre you sure?"if (window.confirm(question)){ var timesheet= new sforce.SObject("Timesheet__c"); timesheet.id = '{!Timesheet__c.Id}'; timesheet.Inclusive_Rate_Validation_Override__c = {!NOT(Timesheet__c.Inclusive_Rate_Validation_Override__c )}; timesheet = sforce.connection.update([timesheet]); window.parent.location.href="/{!Timesheet__c.Id}";}