I'm not sure this tip is discussed anywhere, so I thought I'd share it.
When a form has a numeric field, it initially is blank (assuming you have not given it a default value). However at runtime, once you give it a value, you are not able to clear the field again.with a script unless you click the reset button or reload the form. Unfortunately, that will clear all the fields in the form, not just the one field.
Although you can compare the value of a numeric field to null, you cannot assign a null to a numeric field. The best you can do is give the field a zero value.
However, I found that you can clear a numeric field by doing the following:
input.NumericFieldName = null.toDecimal(); or input.NumericFieldName = null.toLong();
BUT... There is one catch! Once you save the script, and reopen the script again, the line will look like this:
input.NumericFieldName = ;
As long as you don't save the script again, it will not be a problem. But if you try to save the script, an error will be displayed. You will need to go to that statement and retype the line again before saving the script.
I usually place a comment immediately above the statement to remind me what the original statement was if I need to edit the script again. Something like this: