@fullcurrency: unspecified data returns 'undefined' error

Hi there,

I want to display @fullcurrency(#cash^amount) only if a user has entered a sum of money.

I tried using

@if(#cash^amount, @fullcurrency(#cash^amount), @empty-list)

However, as long as the datafield #cash^amount is unspecified, @fullcurrency will display a ‘undefined’ error.

Specifying data resolves the undefined error:
image

I believe this is not consistent with how ‘undefined’ errors work.

For example, if @fullnr is not specified, it will display “zero” instead of an error. Both below datafields are unspecified:

Hi Kai,

While I defer to @mtruyens on whether the behaviour of @if in this case would be desirable in his view, I can already suggest another special function which would be more suitable for this use case.

The @cascade was specifically developed to handle cases where you want to define fallback values to be displayed if a (or any number of) expression(s) evaluate to nothing (e.g. false, zero,…).

E.g. @cascade(@fullcurrency(#cash^amount), @empty-list) will show @empty-list if no value has been assigned to #cash^amount.

So @cascade is the special function to use in these cases as opposed to @if.

Ah, I always forget to use @cascade - thankyou!

Yes, this solves it.

1 Like