I have a report type parameter that determines which parameters the report needs to run.
I created a new enum for the Report type, available options are Job Number or Invoice Number.
If the job number is selected there will be a start job number and end job number with labels "Starting number" and "Ending number." If Invoice Number is selected there will be a start invoice number and an end invoice number with the exact same labels.
Since the job number is the first enum, I decided to build the parameters as if Job number were selected. However, if the user selects invoice number and that is stored in usage data, the parameter screen would need to accommodate that and show the correct parameters based on the invoice number report type selection.
I created a UI Builder class to accomplish this. My report is already using a contract class to define the 5 parameters I need for the report, a controller class, and a DP class to process the report. In the build() method of the UIBuilder class, I add all the dialog fields I will need and then I set visible = false for the invoice start and end fields.
In the postRun() method (before the super()), I check the value of the reportType enum. PostRun() gets called after the usage data is stored in the field(s). If the reportType is InvoiceNumber, I set the jobstart/end fields to visible = false and the invoicestart/end fields to visible = true.
This works nicely.
I also had to override the modified method of the reportType parameter in order to change the parameters shown when the user modifies the report type. For this, I used the postBuild() method tell the system to override the modified() method and where to go to find the new logic for this method.
Ensure that you use the right form control for your field type. For example, my enum reportType is a comboboxcontrol. If your field is a string, you would need a FormStringControl. If your field is an Int you would need a FormIntControl, etc. Your modified() method will need to pass that same type of control as well.
Good luck!
No comments:
Post a Comment