title: How to assign 'blank' to a Decimal field in Salesforce
body: <p>I'm having problems with one of our custom validation rules that forces me to have 'blank' value in a custom field based on certain conditions. </p>
  
  <p>When editing the field manually through the interface, I just erase the content of the text box and it saves fine. But with apex code, how can I put the 'blank' value inside the field ? Assigning null to the field does not seem to make it work. I checked the developper console for the logs and null is correctly being assigned to my property, but the update still throws an exception with a message like :</p>
  
  <pre><code>FIELD_CUSTOM_VALIDATION_EXCEPTION, CustomField; must be blank: [CustomField__c]
  </code></pre>
  
  <p>Here is how I assign null in the apex code :</p>
  
  <pre><code>customObject.CustomField__c = null;
  update customObject;
  </code></pre>
  
  <p>Assigning zero does not work either, as the validation rule needs the field to be 'blank'. Is there a hidden trick which allows me to do this through apex ?</p>
  
  <p>EDIT : Here is the validation formula. If it evaluates to true, there is an error :</p>
  
  <pre><code>AND( ISPICKVAL(CustomStatusField ,'Custom Value') , !ISBLANK(CustomField__c )))
  </code></pre>
  
  <p>So the validation basically is : When <code>CustomStatusField</code> is equal to <code>'Custom Value'</code>, <code>CustomField__c</code> must be blank.</p>
  
  <p>EDIT #2 :
  I finally solved my problem. The above code worked as expected but there was another sneaky trigger that caused the field to be updated to a non-null value, thus making the validation rule fail. God I hate extensive use of triggers for business logic !</p>