web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Phone # formatting (mobile, land line, local, international!!!) how to standardize????

(0) ShareShare
ReportReport
Posted on by 4,515

Hi,

I have been researching on this topic some time but having trouble finding much information. I am trying to find what is best solution to create minimum formatting for phone # field to have some sort of standardization as currently we are getting a lot of bad data!!!

- Our users are in: US, UK and Bermuda(by teams). They also travel quite a bit to different countries

- and calls includes mobile and landlines

- local and international (calling UK, US, Switzerland)

Is there a way to to create some sort of minimum formatting for all users? Obviously XXX-XXX-XXXX does not work for all the users..

Does it make sense to have 001 or just use + for dialing out before phone #??

Any advice/suggestions would be greatly appreciated!! thanks so much

Dan

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Hosk Profile Picture
    on at

    validating phone numbers is not a straight forward problem.  One of the basic checks is to make sure it's a certain length. Probably one of the hardest jobs is to work out exactly what your rules are for validation.

    I think the best way to tackle this is use a javascript function and in that function you can do a number of checks

    before I checked the validation of the number I would remove dashes and brackets and just concentrate on validating the number.

    You could then validate the first part of the phone and check it's an international code. If it wasn't an international code then you could check it was a valid mobile

    I would then use regular expression to check it was the a certain length

    If the validation is to difficult you may want to make the users select a drop down for country/mobile

    here is some javascript I created to validate uk mobile

    javascript:void(0);

    function checkUKTelephone(telephoneNumber) {

       /// <summary>

       /// validates a uk mobile phone number

       /// </summary>

       // Convert into a string and check that we were provided with something

       var telnum = telephoneNumber + " ";

       if (telnum.length == 1) {

           telNumberErrorNo = 1;

           return false

       }

       telnum.length = telnum.length - 1;

       // Remove spaces from the telephone number to help validation

       while (telnum.indexOf(" ") != -1) {

           telnum = telnum.slice(0, telnum.indexOf(" ")) + telnum.slice(telnum.indexOf(" ") + 1)

       }

       // Remove hyphens from the telephone number to help validation

       while (telnum.indexOf("-") != -1) {

           telnum = telnum.slice(0, telnum.indexOf("-")) + telnum.slice(telnum.indexOf("-") + 1)

       }

       // Remove hyphens from the telephone number to help validation

       while (telnum.indexOf(")") != -1) {

           telnum = telnum.slice(0, telnum.indexOf(")")) + telnum.slice(telnum.indexOf(")") + 1)

       }

       while (telnum.indexOf("(") != -1) {

           telnum = telnum.slice(0, telnum.indexOf("(")) + telnum.slice(telnum.indexOf("(") + 1)

       }

       while (telnum.indexOf("+") != -1) {

           telnum = telnum.slice(0, telnum.indexOf("+")) + telnum.slice(telnum.indexOf("+") + 1)

       }

       if (telnum.indexOf("44") == 0){

           telnum = telnum.replace("44", "0");

       }

       var exp = /(070|071|072|073|074|075|076|077|078|079)\d{7,8}$/;

       if (exp != null) {

           //if the regular expression is wrong I don't want to show the user, we can use F12 to debug

           try {

               if (exp.test(telnum) != true) {

                   telNumberErrorNo = 5;

                   return false;

               }

           }

           catch (err) { }

       }

       // Telephone number seems to be valid - return the stripped telehone number  

       return telnum;

    }

  • Verified answer
    Remon Profile Picture
    1,485 on at

    Hello Dan,

    I've used Google's PhoneFormat Library (code.google.com/.../libphonenumber), which is combined to a single .js file and can be used.

    It's a large library, but once cached your users won't notice.

    Check: http://www.phoneformat.com/ (shows output and also the .js file)

    Ask a developer if your not that Javascript minded, it doesn't take a lot of effort to implement this in CRM.

    Good luck,

    Remon Boonstra

  • donyc Profile Picture
    4,515 on at

    Thank you both for your feedback..

    @Remon, this approach looks interesting. If I understand correctly, the user will first have to choose the country before the validation rule is applied? Is there more information exactly how this could be implemented, something for less tech savvy guy like me :)

    @Ben, thanks for your efforts with the code mate. It looks like what Remon suggested is something similar with already pre built validations? Please forgive me if thats not the case, I am not much of a tech guy!

    Thanks again gents


    Dan

  • Community Member Profile Picture
    on at

    Hi Dan, I'm also new to CRM. Your help will be greatly appreciated. Were you able to integrate the solution that @Remon mentioned?

    Any advice, would be great.

    Cheers,

    Alan

  • Community Member Profile Picture
    on at

    Hi Dan were you able to use GitHub Assembly ? 

    If yes Please Let us know how ?

    Stuck somewhere with same kind of requirement.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans