Friday, February 5, 2016

AX - SSRS - SrsReportDataProviderPreProcess - Warning the user of a long run time

When running a preprocessing type of report it may cause the users AX client to freeze. So in order to let them know that it is actually running we may want to alert the user and give them the ability to choose not to run the report.

We can do this by overriding the preRunValidate() method on the controller class.

protected container preRunValidate()
{
    //let the user know that it will take a while to run
    return [SrsReportPreRunState::Warning, "This report may take a long time to run are you sure you want to run it?"];
}

SrsReportPreRunState (ENUM) is the type of alert. You can choose the following types

SrsReportPreRunState::Warning - will allow the user to choose if they should run the report or not
SrsReportPreRunState::Error - will stop the report from running
SrsReportPreRunState::Run - will start the report

Given these 3 types of commands available we can create logic based on current information and what course of action we can take.

By default the container only expects the enum SrsReportPreRunState but if we add a 2nd element then we can override the default text as well thus giving the user a more descriptive alert message.

example

[SrsReportPreRunState::Error, "The report has been canceled because it should only be run during the weekend"];

Thursday, February 4, 2016

AX SSRS - Regular Processing (SRSReportDataProviderBase) VS PreProcessing (SrsReportDataProviderPreProcess) (fixes timeout issues on reporting)

Sometimes in AX we need to create reports that exceed the default run-time limits defined in AX (default is 10minutes) because of the amount of data we are either calculating or returning. As discussed in one of my other posts (AX SSRS Report times out after 10 minutes) one of the ways to overcome this is to change the config files of the client/ssrs server but another way to overcome this limit and improve the speed in which a report can be ran is changing your data provider to extend the class 'SrsReportDataProviderPreProcess' instead of the regular type of 'SRSReportDataProviderBase'

I found this great blog entry over at msdn (click here) with this nice graphic shown below that explains the differences between the two. But long story short the difference is we are utilizing the aos to generate the data then handing the results to ssrs rather than handing the logic to ssrs and letting it generate the data. By doing this we can bypass the time out that is defined in ssrs because the data is already generated before we hand it off and we can improve runtime because it is now generating the data on the aos server.


Regular processing:

Pre-processing:


In order to switch from the regular process we need to make the following changes:

  1. On the table that is returned as a dataset to the report make the following changes
    1. Created by - Yes
    2. CreatedTransactionId - Yes
    3. TableType - Regular
  2. Change the DP class so it extends SrsReportDataProviderPreProcess
  3. Within the DP class.processReport() method add the following code reportData.setConnection(this.parmUserConnection()); where reportData is the table that is returned as a dataset within your report
  4. Execute a incremental cil
  5. Open the SSRS report and hit refresh on the dataset. At this point you should see the field 'createdTransactionId' added to the available field.
  6. Deploy report
  7. Security Note: For your security object it is good to note that when using this preprocessing method you need to add the DPClass.processReport() method to the Server methods node in the privilege associated with the report