cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
freeniels
Advocate II
Advocate II

If condition to see if string contains numbers

Hi guys, 

 

I've been playing around with a Flow that takes a zipcode a input from PVA and connects to Excel for Business to run a script which finds the column that specific zipcode is in and provides a user with information based on that (phone nr., department name etc.). 

 

That script works great if the user actually gives a zipcode (which where I am is 3-4 numbers). I need a way to evaluate if the string contains any letters (or is all numbers), and from what I can see there is no isNumeric function. I am running into a couple of issues. Firstly that the way I am currently evaluating if my variable (a string called 'userzip') passed by PVA is not really elegant: 

freeniels_0-1649235326636.png

Secondly, it doesn't actually actuate the way I want it to, on the string '2400' this condition returns a false and I do not know why. Is there a smarter way to do this? 

 

If a user were to write their village/county instead of postnumber it will also give back wrong values as it will not be able to find anything, so I need a way around that as well as I cannot seem to check that logic in PVA (if someone knows how to do that then do please inform me). So if a user gives "Westershire" instead of "2400" as a 'zipcode' I'd like to return a "this is not a valid zipcode" message, please try again. 

 

I cannot seem to return different values in the control statement for both the yes and the no path, as the flow only seems to allow one "return values to power virtual agent", the way I imagined going around this was setting a boolean to false or similar, returning that to PVA and then letting PVA check if the user gave a valid postcode... Is there a smarter way to do that? 

 

Is there a smart way to say that if we do not get a phonenumber etc. back (which the Office script I am using returns as dynamic values) that makes sense to tell the user to try again? 

 

With kind regards

Niels

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @freeniels 

 

Please have a look at my blog 

 

Microsoft Flow – How to determine a string is numeric? | @mydevexperience #Flownaut Super User III (...

 

Also you mentioned  on the string '2400' this condition returns a false. Try to convert to int() using the expression and evaluate it.

 

If you use expression int() and pass a string value it fails. So you could implement error handling technique which I mentioned in my blog could solve your issue.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

2 REPLIES 2
abm
Super User
Super User

Hi @freeniels 

 

Please have a look at my blog 

 

Microsoft Flow – How to determine a string is numeric? | @mydevexperience #Flownaut Super User III (...

 

Also you mentioned  on the string '2400' this condition returns a false. Try to convert to int() using the expression and evaluate it.

 

If you use expression int() and pass a string value it fails. So you could implement error handling technique which I mentioned in my blog could solve your issue.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
VictorIvanidze
Community Champion
Community Champion

Hi @freeniels,

 

try this:

validatezip.png 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,266)