Skip to content

Customize FilterValue

Patrick Tingen edited this page Sep 28, 2018 · 1 revision

Hooks GetFilterValue and SaveFilterValue are closely related. One is called for setting the value in a data filter and the other is used when the user changes the value.

After the databrowse is created, GetFilterValue is called to get the default value for the filter:

When you change the value of a filter field, SaveFilterValue is called.

Parameters pcDatabase, pcTable and pcField give you the currently selected database, table and field. The pcFilterValue parameter is the value from the filterbox just above the data browse. Note that in GetFilterValue receives it as INPUT-OUTPUT so you can changes it and SaveFilterValue receives it as INPUT.

If you declare a variable to hold the value between calls, you can - for example - set the last used value for a particular field as the default value. See below for an example with Cust-Num.

First, declare a variable to hold the value between calls in the definition part of myDataDigger.p:

DEFINE VARIABLE myCustNum AS CHARACTER NO-UNDO.

Then in the hook SaveFilterValue you want to save the value for Cust-Num:

IF pcField = "Cust-Num" THEN myCustNum = pcFilterValue.

To set this value as the default value, include this in GetFilterValue:

IF pcField = "Cust-Num" THEN myCustNum = pcFilterValue.

Run DataDigger, select the customer table, enter a value for cust-num in the filter and press Enter. You will see the customer of your choice. Now select table 'order'. You will notice that the cust-num you used for the customer table is now filled in in the filter for the cust-num field.

See myDataDigger-filterValues.p for a working example against the sports database.