1. Phil Roth
  2. PowerBuilder
  3. Friday, 24 May 2019 14:29 PM UTC

Is there a way of protecting  a specific column in a DW by referencing by row, e.g. I want to input to column A in 1st row, but disable A in 2nd, Modify does not allow row to be used, so end up disabling all rows.

Does not seem to work in Datawindow by setting expression in General tab / Protect, or in PB script?

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 24 May 2019 14:55 PM UTC
  2. PowerBuilder
  3. # Permalink


You can add an expression to "protect" property in your datawindow for the columns you want to be affected.

How this should be done it depends from what you want to achieve.

If you want to protect a specific column for the second line, the expression to use should be:


The expression should be set to all the columns that you want to be affected.

Also you can add code to the rowfocuschanged event to change the protect property when some situation occurs.

Using describe: .Describe(".Protect")

Using dot notation: .Object.Protect


if currentrow = 2 then
	Object.myColumn.Protect = '1'
	Object.myColumn.Protect = '0'
end if

Finally, there is a way to modify an expression in runtime, but this is more complex...

Ex (modified from help):





There are no comments made yet.
Phil Roth Accepted Answer Pending Moderation
  1. Friday, 24 May 2019 15:55 PM UTC
  2. PowerBuilder
  3. # 1

Thanks Andreas,

worked perfectly, just need to do similar for setting background to silver.

There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 24 May 2019 14:56 PM UTC
  2. PowerBuilder
  3. # 2

You can try adding another column to your select, say call it "s_protect" or whatever you want and put a value of 'Y' in it from your SQL.  Then set the protect attribute for the column you want to limit based on the new column ("If s_protect = 'Y', 1, 0"), then when you want to change only the 1 row value, do a setitem on s_protect to 'N' or anything other than 'Y'.

  1. Phil Roth
  2. Friday, 24 May 2019 15:57 PM UTC
Thanks Kevin, but can't add extra column, as this is an external datawindow, that has to align to an incoming message.
  1. Helpful
  1. Kevin Ridley
  2. Friday, 24 May 2019 18:13 PM UTC
No problem. Most times the dw will ignore the extra column(s) when doing things like importstring, importjson etc, so it should still work. Then you just do a setitem for the one row you need to protect.
  1. Helpful
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.