Skip to main content
Solved

Suppressing certain script output values from showing in email body

  • April 10, 2024
  • 2 replies
  • 24 views

Forum|alt.badge.img+6

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));

Best answer by TheTimeSavingCo

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

2 replies

TheTimeSavingCo
Forum|alt.badge.img+31
  • Brainy
  • 6457 replies
  • Answer
  • April 11, 2024

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

Forum|alt.badge.img+6
  • Author
  • New Participant
  • 1 reply
  • April 11, 2024

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!