Apr 14, 2023 08:15 AM
Hello to you all,
I am trying to create an automation where percentage is taken from the data set to be autocomplete in a gmail message.
Unfortunately, whenever I try to put the token in gmail, it doesn't appear as percentage but as the formula (e.g : 75% appears as 0.75).
I have tried everything - changing the field type (number / single text, long text) and even try to do formula but nothing seems to help...
And another thing : I have tried just putting the number and adding manually in the gmail message the sign "%" and now, my data won't appear at all..
If someone as the solution, I will be really grateful !
Thank you
Apr 14, 2023 09:47 AM
As far as I know, you need to use a script to convert the decimal to a percentage prior to inserting it into your email. To do that, you would add a script action step prior to the send email action. Here's the script you would need to use:
function convertDecimalToPercentage(decimal) {
const percentage = decimal * 100;
const roundedPercentage = Math.round(percentage);
return `${roundedPercentage}%`;
}
// Access the input record and field names from the automation setup
const inputRecord = input.config();
const decimalFieldValue = inputRecord.decimalField;
// Convert the decimal field value to a percentage
const percentage = convertDecimalToPercentage(decimalFieldValue);
// Set the output variable for the automation
output.set('percentage', percentage);
On the left hand side of the script window, create an input variable called "decimalField" and set the value you'd like to convert.
I hope that helps, let me know if you have any other questions.
-Jonathan
Apr 16, 2023 12:32 AM
What if you created a formula field to format the value into a display that you wanted like so:
And the formula used was:
{%} * 100 & "%"