Hiding Records - Concepts?

Hi Folks

I’ve adoptted a process of hiding records that are marked as deleted rather than actually deleting them. I can then let admin users select marked records for re-entry back into the main data set if it was deleted incorrectly. When the user selects Delete the record specified has the column marked_deleted set to 1, and currently, the form is refreshed with a SQL query and loadRecords(). When its brought back into the main population marked_deleted is set back to null and the controller refreshed.

This works fine - but I have trouble deciding the best way to deal with Find() and Serach() on those forms with hidden records?
Using this format:

var vSQL = ‘SELECT fc_id FROM fabric_condition WHERE fc_marked_deleted = NULL’
controller.loadRecords(vSQL);

then the hidden records are not displayed (as expected), however on those forms where I have a Find() and Search() button the returned foundset does not know about the returned column marked_deleted - and hence all the records from the search are returned, including those marked deleted.

One ploy I’ve considered is a hidden field on the form for the marked_deleted column and setting that during the onSearch() to null. My obvious flaw there is that during search() an empty or null field is not considered during the search process = not searched for null?

Second thought was to set marked_deleted to 2 for hidden and 1 for not hidden, then set the form field to 1 in the onSearch() event. This is a little more complex, but more importantly, demands that all current data have a flag set in marked_deleted as default - and I was hoping to avoid that during data transfer and set-up (something else to get missed / go wrong).

How do others handle this process of hiding records marked for deletion - and the search() functions?

Have you tried using a filter?

http://wiki.servoy.com/display/S50DRG/D … ilterParam

indeed, use a tablefilterParam,

that way every query that Servoy does, takes the marked_deleted = null automatically into consideration.
In Servoy5 you can remove that filter, if needed.

Hope this helps

Hi Ian,

from experience with a multitenant environment I can tell you that the link Jan posted above is definitely the most easy way and best way to go.

Some things to take into account:

  1. you can define/set more than one tableFilter on a table, just by setting filters again and again.
  2. every query handled from inside Servoy will be extended with the tablefilters (so find/search, relations, etc.)
  3. getDatasetByQuery will NOT automatically add the filter. Although: when you try to load this dataset onto a form, the filter will be applied onto this dataset.

As for remark 3: this will stand in your way of easy showing records which are marked for deletion.
You can solve this in a couple of ways:

  1. temporarily delete the filter
  2. use the gridbean or solutionModel to show a dataset/datasource.

Hope this helps!

Jan Aleman:
Have you tried using a filter?

Doh… :oops: No I hadn’t Jan.

I’m using them elsewhere in the system and hadn’t even thought of them in this instance but makes perfect sense of course!

Thanks

Ian

Excellent stuff Guys - thanks to all.

That’s a good detailed understanding of how I need to proceed Marc - thanks for the clarity and pointing out the gotcha with point 3.

What a great forum this is !

Ian

Jan Aleman:
Have you tried using a filter?

http://wiki.servoy.com/display/S50DRG/D … ilterParam

Hi Jan,

Don’t you like that fact that you can actually link to up to date documentation to point users right to an answer?

I do!

ptalbot:

Jan Aleman:
Have you tried using a filter?

http://wiki.servoy.com/display/S50DRG/D … ilterParam

Hi Jan,

Don’t you like that fact that you can actually link to up to date documentation to point users right to an answer?

I do!

Agree! Wiki’s are great and hopefully we get the Programming guide live soon too!