the default value of the number field is zero which results in confusion for the sales team … here is the scenario
I have a field called
order_total of type number
and I have another called
collected_amount of type number
now I wanna create a new field called
remaining_amount of type number
the field will be calculated like this
order_total - collected_amount
the thing is, when
collected_amount is null I don’t wanna do the calculation and I wanna set the
remaining_amount to be null too but it gets zero instead which is misleading
I’m using field expression … is there any way I can achieve that without using workflow? thanks
A bit of an unfortunate integration into the default value sanitation flow where the sanitiser defaults the invalid number into the zero-value. This does seem like a bug to me but I’ll check with the team on what exactly we want to do (we’ll probably mark it off as a bug).
Your current options:
Change that expression field into a
Instead of having your expression return
nil you’d return a
""; so something like this:
!(aa ?? false) ? "" : "10" (expression written for my dummy module; adjust as needed).
Not sure what your use cases are, but this would probably do the trick. In this case, your queries would need to change into
field = '' instead of
field IS NULL.
Number field into a multi-value field
This is a bit of a hack, but due to how Corteza handles multi-value fields, for most cases, this should behave exactly the same as the single-value counterpart.
The biggest change would be any workflows since you’d have to iterate the field (or use the
record.values.field) but querying should work out of the box.
The expression would look something like this:
!(aa ?? false)?  :  (again, adjust as needed).
thanks @tjerman, I used the first option as workaround
please update the topic if you decided on a solution to the matter