1. Mitchell Ryan
  2. PowerBuilder
  3. Friday, 23 February 2018 23:00 PM UTC

Hmm.  If this appears twice, please excuse me.

Trying to mask a column in a datawindow (SSN) so upon retrieval its appears as ***-**-1234 (the last four of the SSN).

Then what the user clicks on the row of interest in the datawindow the SSN is unmasked as shows all four digits of the SSN.

Any thoughts how to do this?

 

Accepted Answer
Michael Kramer Accepted Answer Pending Moderation
  1. Sunday, 25 February 2018 14:28 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Mitchell,

I tested the different proposals in previous replies and this one works for me. Pure DataWindow definition. No PowerScript coding.

  1. Use a numeric EditMask for SSN column
    1. Mask= ###-##-####
    2. Visible = yes (no expression)
  2. Computed field:
    1. Compute expression = '***-**-' + Right( String(SSN), 4)
    2. Visible (expression) = if(GetRow( ) = CurrentRow( ), 0, 1)
    3. Enabled = yes
    4. Z-position = "in front of EditMask" (right click > Bring to Front)
  3. Identical "style" for EditMask and computed field :: Font, Colors, Border, Size, and Position
    1. Font = "Consolas" (fixed width) for this EditMask and computed field to avoid nuisance when character widths differ.
    2. Rest of DW uses "Segoe UI" and "Segoe UI Semilight"

Voilá!  --  You can even switch row when clicking on the computed field.

I attach the source code for my DW. (External data source with 2 data rows embedded for testing purpose)

HTH  /Michael

My DW also has additional tests (right-hand side) for combining display formats with Edit and EditMask. All failing without additional coding.

Comment
  1. Michael Kramer
  2. Sunday, 25 February 2018 14:34 PM UTC


release 17;

datawindow(units=0 timer_interval=0 color=67108864 brushmode=0 transparency=0 gradient.angle=0 gradient.color=8421504 gradient.focus=0 gradient.repetition.count=0 gradient.repetition.length=100 gradient.repetition.mode=0 gradient.scale=100 gradient.spread=100 gradient.transparency=0 picture.blur=0 picture.clip.bottom=0 picture.clip.left=0 picture.clip.right=0 picture.clip.top=0 picture.mode=0 picture.scale.x=100 picture.scale.y=100 picture.transparency=0 processing=0 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes print.background=no print.preview.background=no print.preview.outline=yes hidegrayline=no showbackcoloronxp=no picture.file="" )

header(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )

summary(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )

footer(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )

detail(height=424 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )

table(column=(type=char(80) updatewhereclause=yes name=name dbname="name" )

 column=(type=decimal(0) updatewhereclause=yes name=ssn dbname="ssn" )

 )

data("James Bond", 902101007,"Uncle Scrooge", 999999999,)

text(band=detail alignment="1" text="Social Security Number:" border="0" color="33554432" x="18" y="116" height="80" width="704" html.valueishtml="0"  name=ssn_t visible="1"  font.face="Segoe UI Semilight" font.height="-11" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

text(band=detail alignment="1" text="Name:" border="0" color="33554432" x="402" y="20" height="80" width="320" html.valueishtml="0"  name=name_t visible="1"  font.face="Segoe UI Semilight" font.height="-11" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

column(band=detail id=1 alignment="0" tabsequence=10 border="5" color="33554432" x="768" y="20" height="80" width="1646" format="[general]" html.valueishtml="0"  name=name visible="1" edit.limit=0 edit.case=any edit.autoselect=yes edit.autohscroll=yes  font.face="Segoe UI" font.height="-11" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

text(band=detail alignment="0" text="EditMask. No format.

Computed field on top.

~"comp~" hidden in current row." border="0" color="8388608" x="777" y="212" height="204" width="773" html.valueishtml="0"  name=t_4 visible="1"  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="15793151" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

column(band=detail id=2 alignment="1" tabsequence=40 border="5" color="33554432" x="2432" y="308" height="80" width="366" format="***-**-####" html.valueishtml="0"  name=ssn_edit visible="1" edit.limit=0 edit.case=any edit.format="###-##-####" edit.autoselect=no  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="40" )

column(band=detail id=2 alignment="1" tabsequence=20 border="5" color="33554432" x="2432" y="116" height="80" width="366" format="***-**-####" html.valueishtml="0"  name=ssn_useformat visible="1" editmask.useformat=yes editmask.mask="###-##-####"  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="40" )

column(band=detail id=2 alignment="1" tabsequence=30 border="5" color="33554432" x="2432" y="212" height="80" width="366" format="***-**-####" html.valueishtml="0"  name=ssn_noformat visible="1" editmask.mask="###-##-####"  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="40" )

text(band=detail alignment="1" text="Edit Mask, UseFormat = Yes" border="0" color="33554432" x="1682" y="116" height="68" width="727" html.valueishtml="0"  name=t_1 visible="1"  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="40" )

text(band=detail alignment="1" text="Edit Mask, UseFormat = No" border="0" color="33554432" x="1682" y="212" height="68" width="727" html.valueishtml="0"  name=t_2 visible="1"  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="40" )

text(band=detail alignment="1" text="Edit, Format" border="0" color="33554432" x="1682" y="308" height="68" width="727" html.valueishtml="0"  name=t_3 visible="1"  font.face="Segoe UI Semilight" font.height="-10" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="40" )

column(band=detail id=2 alignment="2" tabsequence=50 border="5" color="33554432" x="768" y="116" height="80" width="439" format="[general]" html.valueishtml="0"  name=ssn visible="1" editmask.mask="###-##-####"  font.face="Consolas" font.height="-11" font.weight="400"  font.family="3" font.pitch="1" font.charset="0" background.mode="2" background.color="16777215" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

compute(band=detail alignment="2" expression="'***-**-' + Right( String(SSN), 4)"border="0" color="33554432" x="768" y="116" height="80" width="439" format="[GENERAL]" html.valueishtml="0"  name=c_ssn_nofocus visible="1~tif(GetRow( ) = CurrentRow( ), 0, 1)"  font.face="Consolas" font.height="-11" font.weight="400"  font.family="3" font.pitch="1" font.charset="0" background.mode="2" background.color="16777215" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

htmltable(border="1" )

htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" pagingmethod=0 generatedddwframes="1" )

xhtmlgen() cssgen(sessionspecific="0" )

xmlgen(inline="0" )

xsltgen()

jsgen()

export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )

import.xml()

export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" nativepdf.customsize=0 nativepdf.customorientation=0 nativepdf.pdfstandard=0 nativepdf.useprintspec=no )

export.xhtml()



  1. Helpful
  1. Mitchell Ryan
  2. Thursday, 22 March 2018 22:51 PM UTC
Thank you all for your help.

  1. Helpful
There are no comments made yet.
Miguel Leeuwee Accepted Answer Pending Moderation
  1. Saturday, 24 February 2018 10:50 AM UTC
  2. PowerBuilder
  3. # 1

idea no.1 (easiest way):

Use an edit mask combined with format on the column:

1. Set the format to ****-**-xxxx and activate the checkbox "use format"

2. Set the edit mask to xxxx-xx-xxxx 

The edit mask will be active when you click on the column in a row or when the column receives focus.

The format will be used for the column in other possible rows you might have.

 

Idea no.2:

Use a computed column to show "****-**-" + right(your_column_name, 4) and hide the "normal column" (the one with readable contents) and computed column depending on the row being active or not:

When clicking on a column or row / rowfocuschanged event, then have the computed column being hidden and the normal column being visible. To achieve this you can use an expression in the visible attributes like "if( currentRow()= getrow(), 1, 0)"  (this would work for the "normal column", for the computed column the expression has to switch the 1 and the 0, to do the opposite). 

HIH,

MigueL

Comment
  1. Miguel Leeuwee
  2. Monday, 26 February 2018 10:29 AM UTC
Hello Michael,



Don't know what issue you had when you say "That was one of my failed tests in reply below", but both of my ideas work, as confirmed by you. The only thing is that I used a mask with initial 4 "xxxx" and "****" while the person who asked for ideas has used only 3. Maybe that made your test fail. Also, in "Idea 1" I don't say anything about setting visibility, that's for idea no.2.

  1. Helpful
  1. Michael Kramer
  2. Monday, 26 February 2018 15:14 PM UTC
Heyi Miguel,



Example value SSN = 123456789. Now, format = '***-**-####' will display ***-**-1234. I believe the request is to display ***-**-6789. And true, no need for playing around with Visible setting. (I guessed 4 stars/hashtags was typo)



I used Visible, Enabled, and Z-order because the computed field and edit mask are located on top of each other. And when clicking the computed field on a different row, I wanted row focus to move, display the edit mask (because of hiding the computed field), and move item focus to the edit mask..Otherwise focus remains on current row if you click the computed SSN on another row despite focus moving when clicking any other column. It felt weird from a usability point of view.

  1. Helpful
  1. Miguel Leeuwee
  2. Wednesday, 28 February 2018 23:39 PM UTC
Ahh, I see what you mean now Michael and yes you are very right, sorry about that.

  1. Helpful
There are no comments made yet.
Moshe Tangi Accepted Answer Pending Moderation
  1. Saturday, 24 February 2018 06:53 AM UTC
  2. PowerBuilder
  3. # 2

hi

i think just add a column in database with the ssn masked as wanted , so you can n one hand show masked column but on the other hand can use the real ssn from the first field

 

hth

 

moshe

Comment
There are no comments made yet.
Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Saturday, 24 February 2018 00:08 AM UTC
  2. PowerBuilder
  3. # 3

Hi Mitchell,

 

What version/build of PowerBuilder are you using?

 

Regards,

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.