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
bkmmspbkmmsp 

Set number field to 0 or empty

I have an existing record with a number field that I can use AJAX/JavaScript to update the field to any number but zero.  Is there are trick to setting a number field to either "0" or null/empty.
 
I am using AJAX 8.0 / Javascript and using the new sforce.SObject() method.
 
I have tried fieldname = 0; fieldname = "null"; field name = "nothing"; fieldname = "empty"; and seeting a variable to 0 then fieldname = variable;
 
As soon as I set the fieldname = 1 it successfully updates.
 
Thanks in advance...
 
BKM
cheenathcheenath
Try:

fieldname = null;





bkmmspbkmmsp

Cheenath,

Thanks for the feedback - your suggestion works.  By looking into this with your suggestion, I found that my hang up was actually the fact that I was using another variable in some math, and inadvertantly setting a field to the NaN value given by bad math (like 100/0).  I learned that if one of my numeric fields to be updated is set to this "NaN" I get the error.

Cheers,

BKM