Apr 10, 2024 09:22 AM
I have an automation that is using a script I found on the message boards to format numeric values to currency. It works great. I pull the value from the script into the body of an email automation. However, when there is no value in the field I am using instead of showing nothing in the body of the email it shows 0.00
Below is the script being used. If amount to send in USD for Email is blank how can I suppress the 0.00 from showing in the variable placeholder in the body of the email?
Solved! Go to Solution.
Apr 10, 2024 09:34 PM
Try:
let inputValues = input.config();
let currency = inputValues.currency;
//define function to convert numbers to currencies for report display
function toCurrency(rawValue) {
return (Number(rawValue)).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
if(currency){
output.set("amount to send in USD for Email", toCurrency(currency));
}
else{
output.set("amount to send in USD for Email", "");
}
Apr 10, 2024 09:34 PM
Try:
let inputValues = input.config();
let currency = inputValues.currency;
//define function to convert numbers to currencies for report display
function toCurrency(rawValue) {
return (Number(rawValue)).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
if(currency){
output.set("amount to send in USD for Email", toCurrency(currency));
}
else{
output.set("amount to send in USD for Email", "");
}
Apr 11, 2024 09:15 AM
Thanks! That is what we needed. Appreciate your input!