Skip to main content
Question

Change entered values to positive or negative values

  • November 30, 2017
  • 0 replies
  • 420 views

I have been requested to create a field that changes negative numbers to positive numbers and positives to negative numbers after being entered in the field. I looked at using the ABS but only works with converting negative values to positive but QB has a limitation preventing users from referencing the current field in the formula. 
Any help is greatly appreciated. 
Thanks
This topic has been closed for replies.

You can make a new field and the formula would be

- [my data entry field]

>... too dangerous to change the user's actual input ...
>...  never really being sure what the user entered ...

Human input should always be verified and changed if incorrect, in the wrong format or if a typo is detected. Luckily it is simple to do with script. Here is the core code (for use with IOL) for negating the number entered by your human:
$("#_fid_6").on("change", function() {
  $("#_fid_6").val(- parseFloat($("#_fid_6").val()));
});
Using a formula to do this only bloats your application with superfluous fields (assuming there is no need for retaining the human's original keystrokes).