How to mask a field

If I have a phone number field that I want masked, how would I go about doing this?

***Updated by moderator: Marissa to close post***

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.


Keep up to date on this post and subscribe to comments

June 3, 2008 - 10:36am

I tried JainR001's method of using property set method, but the field is not being masked.

I'm also not following what Patelp02 is refering too when he wrote $mode-show. Can I get a better understanding of what that pseudo code looks like as real code.

So i have a property called .HomePhoneNumber

length of that property would be @length(.HomePhoneNumber)

The rest im not following.

June 3, 2008 - 5:04pm

I would create my own custom Rule-HTML-Property for a field (or set of fields you want to mask).

In the Rule-HTML-Property I would do something like:

<!-- Display Mode -->
<pega:when test='$mode-display' />
// Your masking specific logic goes in here

<!-- Input Mode -->
<pega:when test='$mode-input' />
// Here you would simply display the input field for user to enter data (or additionally, you can mask this as well and have the user over-write what is stored in this field.

Hope that helps.

June 4, 2008 - 10:22am

I created a new Html property called MaskField. After saving it, I tried to select it on the property rule form. I found the html property rule I created, clicked save on the property form, and I got an error "Stream Maskfield is not defined"

Here is also what I have for my MaskField html property rule:
I'm a little unsure about how I am doing the Display mode part. When in display mode I want it still masked, but I don't want the field editable.

<!-- Input Mode -->
<pega:when test='$mode-input' />
<input type="password" name="<pega:reference name='$this-name'/>" value="<pega:reference name='$this-value' mode="LITERAL" />">

<!-- Display Mode -->
<pega:when test='$mode-display' />
<pega:reference name="$this-value" />

June 4, 2008 - 2:12pm

You will need to add the masking logic as part of your code as well.

May 14, 2008 - 11:54am

I done this with Html property using java string using Index.retrieve those charcters required rest of the charcters with "*****", I hope it will solve the problem

May 14, 2008 - 12:10pm

You can use below HTML property

May 14, 2008 - 1:41pm

Thanks for the help. The HTML property rule worked for me


May 19, 2008 - 1:30pm

There is an issue with using thr HTML property set to password.

The problem is that at a certain point in the process when all other fields are greyed out the phone number field with an HTML property of Password to mask the letters remains editable.

Anyone know a way to fix this?

also can I get an example of how to use Index.retrieve for that one field?

May 22, 2008 - 10:42am

U can also do the masking in an activity through using Property-set Method.
As the first step in Property-set Method:
.PROPERTYX == @substring(.PROPERTYX, (@length(.PROPERTYX)-3), @length(.PROPERTYX))
and in the second step

In this example i am masking first three digits of the property (PROPERTYX)

May 22, 2008 - 6:01pm

Another way to approach this issue is by adding an HTML Property Rule to the property that you want masked and conditionally display it such that:

when $mode-show
Display x number of *'s, where x is the length of the data value.
end when

Doing so will not tamper with any values that might have been set for the property already. The question though is (I have not tested this), if the user presses submit the next time, will it take the *'s as the new value for that property or not.

PS: This could be an enhancement to Rules of type Properties, such that a user can check off "masked" when creating the screen/ui's.


April 11, 2016 - 9:30am

You could create a custom Edit Validate Rule. Then call the Edit Validate rule against SSN. 

You could then use an On Click action on a button to load a Section that contains the Full SSN.

Bill Rathert