Help

Suppressing certain script output values from showing in email body

Topic Labels: Automations
Solved
Jump to Solution
252 2
cancel
Showing results for 
Search instead for 
Did you mean: 
HOH_US
4 - Data Explorer
4 - Data Explorer

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?

 

 
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, '$&,');
}

output.set("amount to send in USD for Email", toCurrency(currency));
1 Solution

Accepted Solutions
TheTimeSavingCo
18 - Pluto
18 - Pluto

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", "");
}

See Solution in Thread

2 Replies 2
TheTimeSavingCo
18 - Pluto
18 - Pluto

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", "");
}

Thanks! That is what we needed. Appreciate your input!