Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

My percentage token doesn't match my data

Topic Labels: Automations
1069 2
cancel
Showing results for 
Search instead for 
Did you mean: 
tesscely
4 - Data Explorer
4 - Data Explorer

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

 

2 Replies 2
FlywheelConsult
6 - Interface Innovator
6 - Interface Innovator

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

What if you created a formula field to format the value into a display that you wanted like so:

Screenshot 2023-04-16 at 3.31.33 PM.png

Screenshot 2023-04-16 at 3.31.22 PM.png

Screenshot 2023-04-16 at 3.31.19 PM.png

And the formula used was:

{%} * 100 & "%"