Skip to main content
Best answer

Convert text data to an integer?

  • September 24, 2021
  • 4 replies
  • 2263 views

Forum|alt.badge.img

Using the Formatter string.length I count the length of a string then use that to evaluate a condition in a path. The problem is that the output of string.length is text and not a number. (What?!) This means using “greater than” or “less than” doesn’t work.

 

How do I convert this text into a number so I can actually make use of it?

Best answer by pocaface

@Troy Tessalone Now that I go to test it again, the issue is no longer happening. I swear didn’t change anything other than hard reseting the page! The previous times I tested it, a length of 37 evaluated as both less than and greater than 255 🤷‍♂️.

Thanks for extending your IT aura to my situation.

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • September 24, 2021

Hi @pocaface 

Try using a Code step with the parseInt() function.

The parseInt() function parses a string and returns an integer.

Code: https://zapier.com/apps/code/help

parseInt(): https://www.w3schools.com/jsref/jsref_parseint.asp


Forum|alt.badge.img
  • Author
  • Beginner
  • September 24, 2021

@Troy Tessalone I guess I can spend time trying to figure out how to make that work. It’s frustrating that Zapier doesn’t just output it as length to begin with.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • September 24, 2021

@pocaface

I tested and was not able to replicate your issue.

I successfully took the numeric output from the Formatter > Text > Length step and used the number value in a Filter step that had conditions of greater/less than.

Perhaps post screenshots of how your Zap steps are configured.


Forum|alt.badge.img
  • Author
  • Beginner
  • Answer
  • September 24, 2021

@Troy Tessalone Now that I go to test it again, the issue is no longer happening. I swear didn’t change anything other than hard reseting the page! The previous times I tested it, a length of 37 evaluated as both less than and greater than 255 🤷‍♂️.

Thanks for extending your IT aura to my situation.