ifEmpty not working?
ifEmpty not working?

I have the following in my MVC project:
.Field(new Field("CaseActions.BillingAmount")
.SetFormatter(Format.IfEmpty(0))
)
however, when the postCreate code runs, this field is null and giving me issues in my function
response.PostCreate += (sender, e) => _LogChange(db, "create", e.Id, e.Values);
response.PostEdit += (sender, e) => _LogChange(db, "create", e.Id, e.Values);
response.PostRemove += (sender, e) => _LogChange(db, "create", e.Id, e.Values);
I changed the javascript to add a default value of zero, so that seems to be a band-aid. Why is ifEmpty appear to not be working?
This discussion has been closed.
Replies
The IfEmpty docs state this:
The value
null
is not an empty string, ie,""
.Kevin
ah, so I would need to use a custom formatter. Seems like that would be a common thing.
I’m not quite understanding. Are you submitting
null
from the client-side? If so how? Are you JSON encoding the data you are sending? We send data using HTTP parameters by default, so they are just string values - there is no way to represent types (or indeednull
) hence the need for theIfEmpty
formatter.Allan
sorry, yes, it is blank, not null.
So, my logging code was hanging on blanks until I added this function:
so now no errors and I don't have to default to a zero anymore.
however, I just realized that it seems .SetFormatter(Format.IfEmpty(0)) is still not working (though I no longer require a zero, so I am going to remove this anyway).