1. Tracy Lamb
  2. PowerBuilder
  3. Friday, 31 May 2024 14:11 PM UTC

Hi all,

I'm setting the visible property on column True/False in a datawindow object.  I have two other fields that I base the decision on... uncert_included and accredited_requested.  

Here's the logic behind the visible property:

if ( (IsNull(uncert_included) AND IsNull( accredited_requested ) ), 0,
if ( (uncert_included = 'T') OR (accredited_requested = 'T'), 1, 0))

In the database for this particular record, uncert_included = 'F' and accredited_requested is NULL.

In theory, the column/field should not be visible, but it is.  Can anyone help me fix the logic?  Using PB2022 R3.

Much appreciated!

~~~Tracy

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 15:34 PM UTC
  2. PowerBuilder
  3. # Permalink

Thanks all,

Turns out I didn't have the same logic in the column name at the top of the grid.  I made the following changes Visible property for both the field and the column header:

if ( IsNull(uncert_included) AND IsNull( accredited_requested ),
0,
if ( UPPER(uncert_included) = 'T' OR UPPER(accredited_requested) = 'T',
1,
0)
)

Works like a charm!

~~~Tracy

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 15:05 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Tracy -

I think there is something else going on. There are nine possible permutations. Attached is an exported DW that contains those nine permutations. Row 5 is the case you described, and the expression hides the input field. I created this in PB 2022 R3.

Are the two columns used in the expression both defined as char(1)? Is it possible they might contain a lowercase letter?

Best regards, John

Attachments (1)
Comment
  1. Tracy Lamb
  2. Friday, 31 May 2024 15:38 PM UTC
Both fields are char(1) and a lowercase letter isn't possible inside my app, but you never know what a customer might do outside the app (ie: the database itself). So I added logic to check for convert to upper case first before comparing.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 14:51 PM UTC
  2. PowerBuilder
  3. # 2

Hi Tracy;

  Have you  tried extra brackets ...

if ( ( IsNull(uncert_included ) AND ( IsNull( accredited_requested ) ), 0, if  ( ( uncert_included = 'T' ) OR ( accredited_requested = 'T' ), 1, 0 ) )

Regards .. Chris

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 14:56 PM UTC
  2. PowerBuilder
  3. # 3

Hi Tracy,

You have some parenthesis in the wrong places.

Try this:

if ( IsNull(uncert_included) AND IsNull( accredited_requested ), 
	0,
	if ( uncert_included = 'T' OR accredited_requested = 'T', 
	1, 
	0)
)
Comment
  1. Miguel Leeuwe
  2. Friday, 31 May 2024 14:58 PM UTC
and way too many of them too ... :)

Your "if" starts with a parenthesis and ends with a parenthesis at the end of the 2 possible values, NOT before them.
  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.