From e31f34405eedeb0fa8f824efac5faf3a8c0769e6 Mon Sep 17 00:00:00 2001 From: kishoretk92 Date: Fri, 31 Oct 2025 17:19:31 +0530 Subject: [PATCH 1/2] Create script.js --- .../Percentage Symbol/script.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Percentage Symbol/script.js diff --git a/Client-Side Components/Catalog Client Script/Percentage Symbol/script.js b/Client-Side Components/Catalog Client Script/Percentage Symbol/script.js new file mode 100644 index 0000000000..1685dad322 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Percentage Symbol/script.js @@ -0,0 +1,28 @@ +/*Sets the field value to the formatted percentage string (e.g., 45 becomes 45.00%). + +Retrieves the current value of the field. +Removes any existing % symbol to avoid duplication. +Validates the input to ensure it's a number. +Converts the value to a float. +Formats it to two decimal places and appends a % symbol. */ + + +function onChange(control, oldValue, newValue, isLoading) { + if (isLoading || newValue == '') { + return; + } + + function formatPercent(value) { + if (value === null || value === undefined || value === '' || isNaN(value)) { + return ""; + } + var num = parseFloat(value); + if (isNaN(num)) + return ""; + return num.toFixed(2) + "%"; +} +var des_amount = g_form.getValue("").replace("%",""); + +g_form.setValue("", formatPercent(des_amount)); + +} From 50f727db60e8a3e9de4685aa6b1a2af997529fe6 Mon Sep 17 00:00:00 2001 From: kishoretk92 Date: Fri, 31 Oct 2025 17:20:04 +0530 Subject: [PATCH 2/2] Create readme.md --- .../Catalog Client Script/Percentage Symbol/readme.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Percentage Symbol/readme.md diff --git a/Client-Side Components/Catalog Client Script/Percentage Symbol/readme.md b/Client-Side Components/Catalog Client Script/Percentage Symbol/readme.md new file mode 100644 index 0000000000..61268653b8 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Percentage Symbol/readme.md @@ -0,0 +1,7 @@ +Sets the field value to the formatted percentage string (e.g., 45 becomes 45.00%). + +Retrieves the current value of the field. +Removes any existing % symbol to avoid duplication. +Validates the input to ensure it's a number. +Converts the value to a float. +Formats it to two decimal places and appends a % symbol.