cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VSJadhav
Helper II
Helper II

Add 10 digits numbers into #######-##-# format

Hi Team,

Am using PowerApps portal application where am getting records from excel.
I want to check whether input field value is digit or not.
If its 10 digit number and does not have "-" present in specific places then add it else check whether "-" present in required places or not. If "-" present in wrong places then stop the flow and show error.

The required input to proceed ahead is #######-##-# or ########## and it should have digits only.

Please let me know how to create MS Flow for this.
Thanks,
Vaibhav

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @VSJadhav 

 

Follow the below steps:

 

image.png

 

Next section describes the No condition steps

 

image.png

 

Above I have used formatNumber expression.

 

formatNumber(int(variables('Number')),'#######-##-#')
 
Above I am using the error handler technique to verify whether the number is numeric or not. As you can see above the formatNumber have int() expression. If thats not a number this is going to fail.
 
Next below steps are for the Yes part of the condition.
 
image.png
 
Above formatNumber() expression is as follows:
 
formatNumber(int(replace(variables('Number'),'-','')),'#######-##-#')
 
Same error handling technique I used to determine the whether the number is numeric or not?
 
Note:
 
To set the error handling technique you need to set the following. Click the configure run after then select the option 'has failed'.
 
image.png
 
image.png
 
Above same technique you need to use for Compose 6 as well.
 
Thanks
abm_0-1616803211117.png

 

 
 
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
mahoneypat
Solution Sage
Solution Sage

Checking if a string is an integer is sadly not easy in power automate.  However, here is one way to check your input for a 10 digit number.  Also, see this article for how to configure the run after where shown (after the is10digitnumber step).

 

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

 

This flow replaces '-' with '', check if the string length is 10, and then also tries to check if the int( ) of that string is >0.  The IsInteger variable is initially set to true and set to false only if the Is10digitnumber step fails.  The condition then checks that IsInteger is still true and that the number is 10 digits.

 

mahoneypat_0-1616801288524.png

 

Key Expressions Used Above

 

Is10digitnumber step - 

and(equals(length(replace(outputs('InputText'), '-''')), 10), greater(int(replace(outputs('InputText'),'-','')),0))
 
Condition control - 
and(equals(outputs('Is10digitnumber'), true), equals(variables('IsInteger'),true))

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


abm
Super User
Super User

Hi @VSJadhav 

 

Follow the below steps:

 

image.png

 

Next section describes the No condition steps

 

image.png

 

Above I have used formatNumber expression.

 

formatNumber(int(variables('Number')),'#######-##-#')
 
Above I am using the error handler technique to verify whether the number is numeric or not. As you can see above the formatNumber have int() expression. If thats not a number this is going to fail.
 
Next below steps are for the Yes part of the condition.
 
image.png
 
Above formatNumber() expression is as follows:
 
formatNumber(int(replace(variables('Number'),'-','')),'#######-##-#')
 
Same error handling technique I used to determine the whether the number is numeric or not?
 
Note:
 
To set the error handling technique you need to set the following. Click the configure run after then select the option 'has failed'.
 
image.png
 
image.png
 
Above same technique you need to use for Compose 6 as well.
 
Thanks
abm_0-1616803211117.png

 

 
 
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

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 (1,857)