Skip to main content

Notifications

Announcements

No record found.

Customer Service forum
Answered

Input Mask on Phone field

Posted on by 433

Hi,

We have recently integrated Zoom to Dynamics to allow us to make calls directly from the Contact record using Zoom as the provider, by clicking the phone icon on the Mobile Phone field on a Contact record.

There is an issue with the Zoom integration, in that it will only call if the Contact mobile phone record has a country code beginning with a + first. So for example it will work if the Contact number is +1 123456 but wont work if the contact number is 123456.

I have been looking at input masks on the Mobile Phone field as a workaround. The vast majority of our Contacts phone numbers dont begin with '+123' The would just begin with 123. Anyway, testing it in the Sandbox. When I create the input mask with the format +353 0000000000, the +353 appears in the Mobile Phone field on the Contact. However the phone icon does not. I know this relates to ticking the Web Phone or Tablet Controls in the form properties. But my question is how to I keep the input mask and the phone icon in the form?

Thanks a lot

Ted

  • TedW Profile Picture
    TedW 433 on at
    RE: Input Mask on Phone field

    Hi Nya,

    Many thanks for your suggestion. Its very useful. However my main issue is I believe with the Zoom code. In your first screenshot above, the is no icon on the mobile phone field. I have the phone icon on the Mobile Phone field, but it only launches Zoom if the Country Code, in the majority of our contacts this will be +353, is before it the number. And the vast majority of our Contacts dont have +353 in the mobile phone field. Im not too sure how I would amend your code to reflect that.

    Thanks

    Ted

  • Verified answer
    Nya Profile Picture
    Nya 29,050 on at
    RE: Input Mask on Phone field

    Hi Ted,

    Are you referring to the phenomenon in the screenshot below?

    pastedimage1650616655498v1.png

    Here is a blog about it which also mentioned this issue:

    6 Custom Controls in Power Apps for Data Visualizations - (crmheidi.com)

    pastedimage1650616900920v2.png

     

    1. You can create a JavaScript web resource.

    Here is the code for a similar case.

    function FormatPhoneNo(executionContext) {
    try {
    var formContext = executionContext.getFormContext();
    var nvsField = formContext.getAttribute("telephone1").getValue();
    var nvsTmp = nvsField;
    if (typeof(nvsField) != "undefined" && nvsField != null) {
    nvsTmp = nvsField.replace(/[^0-9]/g, "");
    switch (nvsTmp.length) {
    case 10:
    nvsTmp = "(" + nvsTmp.substr(0, 3) + ") " +
    nvsTmp.substr(3, 3) + "-" + nvsTmp.substr(6, 4);
    break;
    default:
    alert("Phone must contain 10 numeric digits.");
    break;
    }
    }
    context.getEventSource().setValue(nvsTmp);
    } catch (err) {
    alert(err.message);
    }
    }
    1. Open the JavaScript to the Quick Create Form of Contact entity and click the Form Properties.

     Image

    1. Add the JavaScript to the Quick Create Form and set the Event Handle as the image below.

     Image

    1. Add the function.

     Image

    1. Save and publish the form.

    Then the Phone Number will be masked as the format: (xxx) xxx-xxxx.

    Image

    And if a number which has been input does not contain 10 digits, there will be prompt popping up.

    Image

    You need to modify the code yourself for the specific format.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans