How to format currency fields on the form

Hello @ShareSquared,

When you set a field to read-only, it is displayed based on column settings.

If you need to display a currency sign and a specific number of decimal places, you need to change the column settings.

As shown in the screenshot below, the column is already configured as a Currency column (has been since it was created).

And here are the properties of the Field control in the form:

Any ideas?

Hello @ShareSquared,

Please try to re-add the field to the form and clear the browser cache.

If that doesn't help, please make sure that you are using the latest versions of the app package in the App Catalog - v1.0.8.0 and the editor - v1.7.2

:heavy_check_mark: Cleared browser cache w/ Ctrl+F5


No Rounding? :point_down:

And the js:

Hiya @ShareSquared, sorry to but in, but if you are doing the calculation, then you need to format the answer how you want it to be displayed.

fd.field('TotalPayment').value = '$' + totalCost.toFixed(2)

So do the trick!

Hope I helped :slight_smile:

1 Like

Hello @ShareSquared,

Thank you for the details!

In a display form or read-only mode, the 'value' is just a text representation of the field. So when you change a field value, it is treated as a string, and no formatting is applied.

As a workaround, you can enable and hide TotalPayment field on the form, add Plain Text control to display total value formatted and add this code to calculate and display the total.

fd.control('liDataTable').$on('change', function(){
    items = fd.control('DataTable1').widget.dataItems();
    totalCost = 0.00;
       if(items) {
          for(i=0; i<items.length; i++) {
              if(items[i].liAmount){
                 totalCost += items[i].liAmount;
              }
          }
    fd.field('TotalPayment').value = totalCost;
    fd.control('Text1').text = 'Total: $' + totalCost;
}