cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nani
Frequent Visitor

Formatting Phone Number i.e (###)-###-###

Hello guys,

I hope everyone is doing great !

This is Raj, Here I am working on App and I have a requirement to format the Phone number in such a way that (###)-###-####.

Will , Any one please help me in that . 

Thank you in advance,

Raj

11 REPLIES 11
HEATFreight
Post Prodigy
Post Prodigy

Hi all!

I didn't like the complexity or functionality of any of the solutions I have found for this, so I wrote my own as follows. To start with I have hardcoded the output of a "Get My O365 Profile" request into a collection. I removed the O365 profile connector from my canvas apps and flow because I found it to be massively lagging the app launches, thus the hard-coded O365 profile JSON collected into the table which I'll be working with in the following code:

Concat(FirstN(Split(First(colO365Profile.mobilePhone).mobilePhone,""),3),ThisRecord.Result)&"-"&
Concat(LastN(FirstN(Split(First(colO365Profile.mobilePhone).mobilePhone,""),6),3),ThisRecord.Result)&"-"&
Concat(LastN(Split(First(colO365Profile.mobilePhone).mobilePhone,""),4),ThisRecord.Result)


This gives us a ###-###-#### format, but of course you could easily get other formats like:

"("&
Concat(FirstN(Split(First(colO365Profile.mobilePhone).mobilePhone,""),3),ThisRecord.Result)&") "&
Concat(LastN(FirstN(Split(First(colO365Profile.mobilePhone).mobilePhone,""),6),3),ThisRecord.Result)&"-"&
Concat(LastN(Split(First(colO365Profile.mobilePhone).mobilePhone,""),4),ThisRecord.Result)

to get (###) ###-#### format.

The other solution I saw were here and here.

I was unable to get phone number input masking working for the default value of a text input field, which I'm prepopulating with calculated values from other fields and from that hard-coded O365 profile collection. It seems that input masking only works for labels and other non-editable fields, as I think I've seen others mention as well.

The above method is simple, quick, and easy code that's not difficult to parse. I couldn't parse the more complicated solutions at a glance, so that's a no-go for me, especially when an easier solution for my use case is so easily doable.

Hope it's helpful!

Raj2014
Helper II
Helper II

Hello Team ,

I tried with above code if you try enter on 9 digit the value is resetting

Raj2014_0-1660308238581.png

If I typed the above number the values are resting to 

Raj2014_1-1660308295493.png

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,245)