The KBForm openForm and openReport methods take an optional argument which is a dictionary of parameter (name, value) pairs, for instance ( Hopefully, in a future release, it will be possible to support python argument passing like openReport("Clients", Company = "Big%"). )
def eventFunc (button) : button.getBlock().getForm().openReport \ ( "Clients", { Company : "Big%" } ) |
If the Clients report has not defined any user entry paramaters, then it will execute immediately. Assuming that you have done something sensible with the Company parameter such as having a where expression like Company like '${Company:%}', then the report should just show big companies.
This mechanism can be taken to extremes. For instance, you could have a where expression which is just ${Filter}, and then pass the Filter parameter as Company like 'Big%'. This way, you can construct completely arbitrary filters in a script. Below is an example from the RekallDemo database:
# This is comment and not a shortcut, since the leading # is followed # by whitespace. OK, agreed, its a hack! # def eventFunc (button) : text = RekallMain.promptBox \ ( "Enter pattern or leave empty for all", "", "Select companies" ) if text == None : return if text != "" : text = "Company like '" + text + "'" button.getBlock().getForm().openForm ('Client', {'Filter' : text}) |
For reference, here is the KBForm onLoad event for the Client form. This displays a subtlety of inline events. Because the text is just a property like any other property (width, font, etc.), they are subject to parameter substitution, so the script here displays a welcome message, which also shows the filter, if there is one.
def eventFunc (form) : message = "Welcome to the Clients Form!" if "${Filter}" != "" : message = message + "\nFilter: " + "${Filter}" RekallMain.messageBox(message) |