Hi there, 


I'm new to outsystems, and have been integrating an extension with all the databases available on an SQL Server, and displaying a few select fields on a table records in a specific screen.


I have managed to correctly add the list Navigation, the Ajax Refreshing of the table  and the Navigation itself. My "problem" is the following:


I have a list of table records displayed in a combo box, for the user to choose from. When the user chooses one of the available values (it's a static list), then the table is filtered to only display the respective column values that match with the one the user selected. 


However, I tried to add an option of displaying all the records, and for that, on the combo box, I added a Special List value, and assigned it to a local variable. 


Now besides the normal table records I have this extra option, and what I'm doing is If the special variable has the selected value then i show all the values. But I'm implementing this in a completely separate flow, and i'm sure there is a more efficient way of doing this, but I'm not quite sure how, example in the image below (FullPermissions is the filtered table, FullPermissions2 is the non filtered table):




Solution

Hi Ricardo,

if I'm reading this correctly, in the GetFullPermissions you apply a filter with the value selected in the dropdown.  Besides that, you also want the option of not applying this filter and instead showing all records.

You are right that it's not necessary to have a completely separate flow, you just have to adjust your filter slightly.  Since the special value selected goes to a separate 'special variable', when you select it, the normal 'variable' that the normal selected value goes into, is empty.

You can make use of that in your filter of GetFullPermissions


let's say the variable your normal selection goes into is called SearchDatabaseName, then in your aggregate you will have a filter looking something like this


Database.Id = SearchDatabaseId


you just have to change that into 


Database.Id = SearchDatabaseId or SearchDatabaseId = NullIdentifier()


Let me know if I understood your requirements wrong,

happy coding,

Dorine

Solution

Dorine Boudry wrote:

Hi Ricardo,

if I'm reading this correctly, in the GetFullPermissions you apply a filter with the value selected in the dropdown.  Besides that, you also want the option of not applying this filter and instead showing all records.

You are right that it's not necessary to have a completely separate flow, you just have to adjust your filter slightly.  Since the special value selected goes to a separate 'special variable', when you select it, the normal 'variable' that the normal selected value goes into, is empty.

You can make use of that in your filter of GetFullPermissions


let's say the variable your normal selection goes into is called SearchDatabaseName, then in your aggregate you will have a filter looking something like this


Database.Id = SearchDatabaseId


you just have to change that into 


Database.Id = SearchDatabaseId or SearchDatabaseId = NullIdentifier()


Let me know if I understood your requirements wrong,

happy coding,

Dorine


Thanks a lot Dorine! It really was that simple, it's working  like a charm now :)

It's still a bit hard for me to understand the logic though...can you help me phrase the condition so it makes more sense in my head?  I guess what I'm saying in that changed filter is : "My filter condition is that my database.id equals my local variable SearchDatabaseId   OR if my SearchDatabaseID = NullIdentifier() then I apply this filter instead".


I'm never going to apply the first filter condition if the searchDatabaseId is Null, because there is no entry for that in the database.id.


Is this reasoning correct?


Thank you.


 


Hi Ricardo,


you could think of a filter like this : for each row that the aggregate finds in the database, it will evaluate if for that particular row the filter produced a value of either true or false, if true than the aggregate adds the row to the result set, if false it doesn't.  

So in our case, if the filter is 

Database.Id = SearchDatabaseId or SearchDatabaseId = NullIdentifier()

then, since it's an or, the filter will return a true if either of both sides is true

So

  •  if SearchDatabaseId is nullidentifier, then for every row in the table the second part of the expression is true, so this filter will be true for every row
  •  if SearchDatabaseId is filled, then the second part of our filter is false for every row, and then whether the whole filter is true depends on the first part
    • if Database Id = SearchDatabaseID, then filter is true, row is in result
    • If Database Id <> SearchDatabaseId, then filter is false, row is not in result


Edit: when you have more than one filter in the aggregate, then a row is only in the result if all filters result to true

Dorine Boudry wrote:

Hi Ricardo,


you could think of a filter like this : for each row that the aggregate finds in the database, it will evaluate if for that particular row the filter produced a value of either true or false, if true than the aggregate adds the row to the result set, if false it doesn't.  

So in our case, if the filter is 

Database.Id = SearchDatabaseId or SearchDatabaseId = NullIdentifier()

then, since it's an or, the filter will return a true if either of both sides is true

So

  •  if SearchDatabaseId is nullidentifier, then for every row in the table the second part of the expression is true, so this filter will be true for every row
  •  if SearchDatabaseId is filled, then the second part of our filter is false for every row, and then whether the whole filter is true depends on the first part
    • if Database Id = SearchDatabaseID, then filter is true, row is in result
    • If Database Id <> SearchDatabaseId, then filter is false, row is not in result


Edit: when you have more than one filter in the aggregate, then a row is only in the result if all filters result to true

Thanks a lot, made more sense now :)


Happy coding!