Hi!
I have some issues with a variable that i want to use in my html as part of the personalization.
Nowadays, the variable is like this: TotalAmount: 12561.2
But i would like to transform it into something like this: 1.2561,20
Do you know how can i do it? I hope the answer is easy to apply. My first thought was using the "edit an expression" wizard but i didnt find the way.
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @Javi_Landa,
for personalization you can use power of JavaScript so you can format number eg by following script:
function formatNumberWithCommas(number) {
// Split the number into integer and decimal parts (if any)
var parts = number.toString().split("."),
integerPart = parts[0],
decimalPart = parts[1] || "";
// Add commas to the integer part
var formattedIntegerPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
// Combine the integer and decimal parts
if (decimalPart) {
return formattedIntegerPart + "." + decimalPart;
} else {
return formattedIntegerPart;
}
}
// Example usage:
const numberWithCommas = formatNumberWithCommas(1234567.89);
<%=numberWithCommas%>; // Output: "1,234,567.89"
Marcel Szimonisz
MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/
Hello @Javi_Landa,
for personalization you can use power of JavaScript so you can format number eg by following script:
function formatNumberWithCommas(number) {
// Split the number into integer and decimal parts (if any)
var parts = number.toString().split("."),
integerPart = parts[0],
decimalPart = parts[1] || "";
// Add commas to the integer part
var formattedIntegerPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
// Combine the integer and decimal parts
if (decimalPart) {
return formattedIntegerPart + "." + decimalPart;
} else {
return formattedIntegerPart;
}
}
// Example usage:
const numberWithCommas = formatNumberWithCommas(1234567.89);
<%=numberWithCommas%>; // Output: "1,234,567.89"
Marcel Szimonisz
MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/
I'm trying to find how to integrate that formula into the workflow but I'm not finding anything in the documentation.
Can you please explaing how to use it with more detail?
Thanks on advise !
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies