Implementing Format Number Hash on Dynamic Hash Variables

Introduction

You can use the Format Number Hash Plugin to apply number formatting to a dynamic variable. You can format numbers dynamically using this plugin by leveraging nested hash variable formatting.

Get started

Plugin information

  • Plugin Name: Format Number Hash Variable
  • Compatibility: Joget DX 8 and onwards

Get started

Where to get the plugin

You can download the Format Number Hash Plugin from the Joget Marketplace.

How to install

  1. Click Download on this plugin screen (It will be a .jar file).
  2. Go to your Joget localhost or server. In the Joget Console, go to Admin Bar > Systems Settings > Manage Plugins and click the Upload Plugins button.
  3. Under Upload Plugin, select the plugin .jar file you downloaded and click Upload.
  4. Depending on the plugin type, you can now view your new plugin in your form, List, or UI Builder.
  5. Remember to uninstall the old plugin before uploading a new version.
  6. The Joget Knowledge Base has more information on managing and developing plugins.

How to use it

Using format number hash on a datalist

Similar to Format Number Hash for form #formatNumber.{form.table.field}[decimal=2], you can use a similar approach to formatting numbers retrieved from a List Builder. When you have a hash variable that holds the sum or any numerical data from a List Builder, you can format this number by placing it inside the Format Number Hash syntax. This allows you to specify the desired number of decimal places or other formatting options.

For example, if you have a sum of a datalist column being retrieved dynamically, you can add a thousand separators and decimals to it like so:

#formatNumber.{Your_datalist_hash}[decimal=2&thousandSeparator=,]#
For example, if there is a datalist named list_MoneyFlower, the hash variable will be:
#formatNumber.{datalist.col.sum.list_MoneyFlower.column_1}[decimal=2&thousandSeparator=,]#

This will format your dynamic sum with two decimal places and include a comma as the thousand separator.

Format number hash on the arithmetic operation

If you are performing arithmetic operations on data from datalists and wish to apply number formatting to the aggregated total, you can employ a nested expression hash variable. This would involve summing up the columns and formatting the resulting total with the Format Number Hash.

To learn more about using dynamic hash variable values within information tiles, see the relevant documentation page use dynamic hash variable values inside information tiles.

 If you want to have the number formatted on the total value, The hash variable expression for that would be:

#formatNumber.{exp.{envVariable.num1} + {envVariable.num2}}[decimal=2&thousandSeparator=,]#

For example, if you have 4 datalists and you want to add the sum of columns and apply Format Number Hash on the total value, the format would be:

#formatNumber.{exp.{datalist.col.sum.list_Money_University.column_0} + {datalist.col.sum.list_Money_Resort.column_0} + {datalist.col.sum.list_Money_Hamburger_Shop.column_0} + {datalist.col.sum.list_MoneyFlower.column_1}}[decimal=2&thousandSeparator=,]#

Know more at Hash Variable, under the Expression Hash Variable (New) section, on how to use different expressions. Also, see the Format Number Hash Plugin to learn how to format numbers.

Download plugin

Download sample app

Download the demo app for Implementing Format Number Hash on Dynamic Hash Variables:
Created by Julieth Last modified by Aadrian on Nov 22, 2024