Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to mask the phone number on a quick view form?

(0) ShareShare
ReportReport
Posted on by 2

I need to mask the phone number on an Account Contact card (Quick Create Form), can this be done?  If so,  how?  I have done this on the actual Contact form, just can't seem to find a way to do it on a quick create form.

Please advise, thank you.

  • Suggested answer
    Nya Profile Picture
    Nya 29,058 on at
    RE: How to mask the phone number on a quick view form?

    Hi, USA80

    Do you mean to auto format the mask of the highlighted phone number in the image below?

    0.png

    1. If so, you can create a JavaScript web resource.

    Here is the code.

     

    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.

     8880.png

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

     88730.png

    1. Add the function.

     35232.png

    1. Save and publish the form.

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

    pastedimage1613109218527v2.png

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

    pastedimage1613109197122v1.png

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

     

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Nya

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,468 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,287 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans