Update table based on the selected user status

I have a list of users in a table records. One column of the table is the status "Is Active". I have a combo box associated with a session variable "Session.User_Status" and I want to filter the table based on the selected value in the combo box after the user clicks in the "Search" button. However when the user selects a status and clicks in "Search" the table is not updated to show only the users with the selected status.


In the preparation of the Users screen I have this filter:


(Session.User_Status=0 )  or  (Session.User_Status=1 ) or (Session.User_Status=-1)


Do you know where is the issue?


It seems that it works with:

(Session.User_Status= BooleanToInteger(Customer.IsActive) ) or (Session.User_Status=-1)


But also works like below, but Im not understanding how, do you know how?

(Session.User_Status=0 and User.IsActive = False )  or  (Session.User_Status=1 and User.IsActive = True) or (Session.User_Status=-1)

Hi,

Your first filter does not filter on the User.IsActive attribute. 

The second and third variant do filter the User.IsActive based on your session variable.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi,

Your first filter does not filter on the User.IsActive attribute. 

The second and third variant do filter the User.IsActive based on your session variable.

Regards,

Daniel


Thanks, but for example this filter:

(Session.User_Status= BooleanToInteger(Customer.IsActive) ) or (Session.User_Status=-1)

Its like a where clause, where Customer.IsActive column value is equal to the value in the Session.User_Status, so if the value in the session is 0 it returns only the records with IsActive column false, if the value is 1 it returns only the records with IsActive column true. And its filtering the User.IsActive based on the session variable Session.User_Status.


But in this filter:

(Session.User_Status=0 and User.IsActive = False )  or  (Session.User_Status=1 and User.IsActive = True) or (Session.User_Status=-1)


although it works, I'm not understanding how and if it's correct. Can you explain how in this case the filter of the User.IsActive is also based on the session variable?





Solution

 BooleanToInteger(Customer.IsActive) translates into 0 or 1 based based on User.IsActive is False or True.

(https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Data_Conversion

So, lets get  or Session.User_Status=-1 out of the equation. that condition is there to see all records. Equal filter in both versions.

Your first variant of the filter:

Session.User_Status= BooleanToInteger(Customer.IsActive)

Below is the 4 possible combinations of Customer.IsActive and Session.User_Status (excluding -1 for UserStatus)

Now have a look at the second filter variant, so you see it will select exactly the same 2 records.

 (Session.User_Status=0 and User.IsActive = False )  or  (Session.User_Status=1 and User.IsActive = True) 

Just making a truth table out of all possible combinations clarifies it.

Solution

Daniël Kuhlmann wrote:

 BooleanToInteger(Customer.IsActive) translates into 0 or 1 based based on User.IsActive is False or True.

(https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Data_Conversion

So, lets get  or Session.User_Status=-1 out of the equation. that condition is there to see all records. Equal filter in both versions.

Your first variant of the filter:

Session.User_Status= BooleanToInteger(Customer.IsActive)

Below is the 4 possible combinations of Customer.IsActive and Session.User_Status (excluding -1 for UserStatus)

Now have a look at the second filter variant, so you see it will select exactly the same 2 records.

 (Session.User_Status=0 and User.IsActive = False )  or  (Session.User_Status=1 and User.IsActive = True) 

Just making a truth table out of all possible combinations clarifies it.

Thanks!

But for example, in sql terms we can have select * from users where User.IsActive = Session.User_Status, that should translate in select * from users where User.IsActive = true (if the Session.User_Status value was 1). And this should return all users that have the IsActive column as true.

But in that table, using this scenario, when the Session.User_Status is 1, it should return all records that have the IsActive column as true, however in that table there is a "No" in the "Records selected" when the Session.User_Status is 1 and the User.IsActive is True (1).