Decimal fields are shown as blank on UI when the value is ZERO

edited March 1, 2017 in Questions
Hi,

I have few currency fields displaying on UI as a template field in a table.
When a field value is ZERO, it shows as blank on UI.

Here is the template formula :

{{#discountedPrice}}<div style="font-weight: bold">{{currencyCode}} {{discountedPrice}}</div>{{/discountedPrice}}{{#discountedPrice}}<div style="color :DimGray ;text-decoration: line-through">{{currencyCode}} {{listPrice}}</div>{{/discountedPrice}}
{{^discountedPrice}}{{#listPrice}}<div style="font-weight:bold">{{currencyCode}} {{listPrice}}</div>{{/listPrice}}{{/discountedPrice}}

discountedPrice
listPrice  - When both of these are ZERO, it shows as blank.

Expected is : 0.00

What I want to do is : display values if it's not null (Meaning ZERO or any other value except null)

What changes should I have to make for this formula ?




Comments

  • edited March 1, 2017
    Hi KVin,

    It looks like the merging language we use (mustacheJS) does not distinguish between 0 and nulls for its out of the box functionality. So the template is not showing any content when both discountedPrice and listPrice are 0. You could add a section like the bold one below, but then it would treat null values as 0's and they would show up as 0.00.

    {{#discountedPrice}}
        <div style="font-weight: bold">{{currencyCode}} {{discountedPrice}}</div>
    {{/discountedPrice}}

    {{#discountedPrice}}
        <div style="color :DimGray ;text-decoration: line-through">{{currencyCode}} {{listPrice}}</div>
    {{/discountedPrice}}

    {{^discountedPrice}}
        {{#listPrice}}
            <div style="font-weight:bold">{{currencyCode}} {{listPrice}}</div>
        {{/listPrice}}
        {{^listPrice}}
            <div style="font-weight:bold">{{currencyCode}} 0.00</div>
        {{/listPrice}}
    {{/discountedPrice}}

    I think Skuid should add another built in merge function similar to {{#encodeUrl}}{{/encodeUrl}} called {{#isNumberZero}}{{/isNumberZero}} or something like that. That way you could differentiate between zero and null in your merges. 

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!