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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to format Email address like S********@outlook.com

(0) ShareShare
ReportReport
Posted on by 95

Hiii Everyone

                    I need to format the emailaddress1 field into format s*********@outlook.com.

that means First Letter of emailaddress1 remains same and remaining letters as *********.

Can anyone help me get above scenario

*This post is locked for comments

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to format Email address like S********@outlook.com

    Hi Sreekant,

    Can you share some.more examples of.what you trying to achieve?

    Also, when you say *, do you mean the actual character or any value in place of *?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: How to format Email address like S********@outlook.com

    You can use regular expressions, but if you still need to use that email address for another purpose, this is a bad idea, because it would replace the actual value of the email.

    Why not use Security Profiles, and make the emailaddress1 field Secured?

    The other option, if you need to keep both the emailaddress1 field for later use, and display this field, is create another field (for example: securedEmail). Have the email address as Can Create.

    When the email address is created, add logic to replace the value and store it in the securedEmail field.

    This will make the emailaddress1 as a Secured Field, and the securedEmail field as unsecured, but not containing the actual email address.

    If this was not your intention, please clarify.

  • Sreeekanth Profile Picture
    95 on at
    RE: How to format Email address like S********@outlook.com

    I have a "Email" field and "Secured email" filed.

    Email --- sreekanthcan@outlook.com

    Secured Email -- s***********@outlook.com

    Later I will use Secured email field for verification purpose

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: How to format Email address like S********@outlook.com

    So, you can use Regular Expressions to get the value of the email address you are looking for and replacing it with what you want. See following post:

    www.bennadel.com/.../207-ask-ben-extracting-parts-of-an-email-address-in-javascript.htm

    Or you can just find the index of the @ in javascript, replace the part before with the *, and save it in the new field, or you can split it by using the split method. The code below should do it. Didn't try, but please go ahead...

    var splitEmail = emailAddress.split('@');

    var prefix = splitEmail[0];

    var output = prefix.substring(0,1) + padleft("*", prefix.length-1) + "@" + splitEmail[1];

    padleft = function(padString, length) {

    var str = this;

       while (str.length < length)

           str = padString + str;

       return str;

    }

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to format Email address like S********@outlook.com

    Hi Sreekanth,

    You could use the below javascript method (may be on change of email or on save) to format the secure field. Just tried and it seems to be working fine.

    ---------------------

    function setSecureEmail()

    {

       var email = Xrm.Page.getAttribute("emailaddress1").getValue();

       if (email != null)

       {

           var txt = email.split('@')[0];

           var result = "";

           for (var i = 0; i < txt.length; i++) {

               if (i === 0) {

                   result = result + txt.charAt(i);

               }

               else {

                   result = result + '*';

               }

           }

           result = result + "@" + email.split('@')[1];

       }

       Xrm.Page.getAttribute("new_secureemail").setValue(result);

    }

    ---------------------

    Hope this helps.

  • Suggested answer
    Sreeekanth Profile Picture
    95 on at
    RE: How to format Email address like S********@outlook.com

    HII Aric Levin

                 Thanks for your suggestion ,I Got it.

  • Suggested answer
    Sreeekanth Profile Picture
    95 on at
    RE: How to format Email address like S********@outlook.com

    Hiii  Ravi BRO

                     I tried script its working fine. Thank you so much

  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to format Email address like S********@outlook.com

    Thanks Sreekanth.

    Please close the thread by marking the suggestion as helpful. This will help others in need.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans