Friday, October 30, 2020

Designing SSRS reports easier

My first big tip is to always create an AutoDesign report with your data. Use the style template that gives you the pieces you need and then you can always right-click on your AutoDesign and "Create Precision Design" from it. Then you get a precision design where you can just move around the objects. It gives you something to start from so you aren't just drawing text boxes on your screen.

I'm currently working on a project where they always want the Font to be Arial and the size to be 10pt. The default ReportLayoutStyleTemplate uses Segoe UI and the data in the rows are 8pt size. You can find the ReportLayoutStyleTemplate in the AOT. Duplicate it into your project and modify the font and size for the sections you need. When you build your project, you will now see that new template as an option in your AutoDesign Layout Template drop-down. Now when you generate the Precision Design, it will use the font that you set up from that template.

Hope I explained that well.

Good luck!

Thursday, October 22, 2020

AX SSRS Report - How to modify parameter properties based on usage data values

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!