codemann8
codemann8

Reputation: 390

Get dialog result of SSRS parameter form

From a report controller object, I'm trying to figure out how to find out if the user has canceled the SSRS report dialog screen or if they hit OK.

In AX, I'm trying to write a controller that will execute two different designs of the same report object, both will use the same contract (parameters). So far I have this code:

cusController controller;
cusContract   contract;

//Run Format 1
controller = new cusController();
controller.initController(_args);
controller.parmReportName(ssrsReportStr(cusReport, Format1));
controller.parmShowDialog(true);
controller.startOperation();

//Run Format 2
contract = controller.parmReportContract().parmRdpContract() as cusContract;
contract.parmFormat(cusReportFormat::Format2);
controller = new cusController();

controller.initController(_args);
controller.parmReportName(ssrsReportStr(cusReport, Format2));
controller.parmShowDialog(false);
controller.parmReportContract().parmRdpContract(contract);
controller.startOperation();

The above works perfect when the user enters in parameters and hits OK. However, when the user hits Cancel the first report cancels, but since the second report has parmShowDialog(false), it doesn't know the first report was canceled. Any ideas on how to capture the Cancel from the first report?

Upvotes: 2

Views: 1618

Answers (1)

Alex Kwitny
Alex Kwitny

Reputation: 11564

Depending on what your controller class extends, I think you would do something like this. I've seen it done a ton of different ways:

    SysOperationStartResult         result;

    // Method 1
    result = controller.startOperation();
    if (result == SysOperationStartResult::Started ||
        result == SysOperationStartResult::AddedToBatchQueue)
    {
        info("They clicked ok");
    }

    // Method 2
    if (controller.prompt())
    {
        controller.run();
        info("They clicked ok");
    }

Upvotes: 2

Related Questions