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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Mask Phone Number But retain original while click to Dial

(2) ShareShare
ReportReport
Posted on by 24
I’m working with multiple entities (e.g., customers, leads, contacts), each containing phone numbers of varying lengths. I need to display masked versions of the phone numbers for privacy (e.g., in UI or logs), while still being able to access and use the original number for operations like click-to-dial.
Example Use Case:
  • Displayed on screen: +1-*****3210
  • Original value used for dialing: +1-9876543210
Requirements:
  • Phone numbers can vary in length and format (some may include country codes).
  • Masked version should:
    • Preserve last 3–4 digits.
    • Optionally keep prefix (e.g., +1).
    • Original (unmasked) number must remain accessible for backend logic like click-to-dial.
  • Must work across multiple entities consistently.
  • Should avoid storing two versions of the number if possible—masking should be on-the-fly or display-only.
Questions:
  1. What is the best way to implement this masking logic (UI masking vs data masking)?
  2. How can I ensure the original number is still used for dialing while showing only a masked version in the UI?
  3. Are there recommended libraries, functions, or design patterns for this use case in [your tech stack]?
Any suggestions, best practices, or code examples would be greatly appreciated!
Categories:
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    303,669 Super User 2026 Season 1 on at
    Hi Jazeb,
     
    Can you tell us what Dynamics 365 application this question is related to? There are several different solutions in the Dynamics 365 family, like: Sales, Finance, Supply Chain Management, Project Operations, and Business Central.
     
     
  • Suggested answer
    DAnny3211 Profile Picture
    11,417 Super User 2026 Season 1 on at

    Hi,

     

    To implement phone number masking while retaining the original number for operations like click-to-dial, here’s a recommended approach based on best practices in Dynamics 365 and general UI design:

     
     

    Recommended Strategy

     

    1. UI Masking (Display-Only)

     

    • Mask the number on-the-fly in the UI using a formatting function.

    • Example logic:


    •  
     
      function maskPhoneNumber(phone) {
          const prefixMatch = phone.match(/^(\+[\d]{1,3})/);
          const prefix = prefixMatch ? prefixMatch[1] : '';
          const lastDigits = phone.slice(-4);
          return `${prefix}-*****${lastDigits}`;
      }
    
     

    • This ensures the original number remains untouched in the database and backend logic.


    •  
     

    2. Click-to-Dial Logic

     

    • Use the original number in the href attribute for dialing:


    •  
     
      <a href="tel:+19876543210">+1-*****3210</a>
    
     

    • This way, the user sees the masked version, but the dialer uses the full number.


    •  
     

    3. Centralized Masking Function

     

    • Implement a reusable function in your front-end layer (e.g., JavaScript, TypeScript, or XRM scripts) to apply consistent masking across entities.


    •  
     

    4. Avoid Storing Masked Values

     

    • Keep only the original number in the database.

    • Masking should be applied dynamically during rendering or logging.


    •  
     
     

    Best Practices

     

    • Security: Ensure masking is applied consistently in logs, exports, and UI to protect sensitive data.

    • Performance: Avoid complex regex or transformations in large datasets—use lightweight masking logic.

    • Scalability: If using Power Apps or model-driven apps, consider using calculated fields or PCF controls for dynamic masking.


    •  
     
     

    Please verify if this approach aligns with your use case or if you'd like a code sample tailored to a specific tech stack.

     

    Thanks and best regards,

    Daniele

    Note: This response was prepared with support from Copilot to ensure clarity and completeness.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 156

#2
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans