Best answer

Convert text data to an integer?

  • 24 September 2021
  • 4 replies
  • 1509 views

Userlevel 2
Badge

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?

icon

Best answer by pocaface 24 September 2021, 19:27

View original

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

Userlevel 7
Badge +14

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

Userlevel 2
Badge

@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.

Userlevel 7
Badge +14

@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.

Userlevel 2
Badge

@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.