web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Controller class run code after prompt but before report is printed

(0) ShareShare
ReportReport
Posted on by 313

Hello everyone,

I'm posting a new thread for a new question that came from this post
Pass parameter from form to report - Dynamics 365 Finance Forum Community Forum

Right now I'm running a SSRS report and need to create a record of that report being run.  The problem is the way I have it at the moment, it creates the records before it's even prompted where you want to print the report.  So if you click cancel, the records are already in the table.

I would like to be able to create the records after the prompt, but before it attempts to print the report.

I put the line of code that creates the record AFTER startOperation() but that runs after the DSP class has been called (DSP class is Docentric class)

Does anyone have a suggestion how I should do what I need?

Here is my controller class now.  You can see I commented out the createReportData(), made a new method that just grabs the next packingSlipId so we can put it in the contract, and then attempted to put createReportData after startOperation() but this isn't working right

class TCI_OutsideServicePackingSlipController extends SrsReportRunController
{
    TCI_OutsideServicePackingSlipHeader packingSlipHeader;
    TCI_OutsideServicePackingSlipId     packingSlipId;
    public static void main(Args _args)
    {
        TCI_OutsideServicePackingSlipController     controller = new TCI_OutsideServicePackingSlipController();
        
        controller.parmReportName(ssrsReportStr(TCI_OutsideServicePackingSlip, Report));
        controller.parmArgs(_args);
        //controller.createReportData();
        controller.getPackingSlipId();
        controller.startOperation();
        controller.createReportData();
    }

    private void getPackingSlipId()
    {
        packingSlipId = NumberSeq::newGetNum(ProdParameters::numRefTCI_OutsideServicePackingSlipEDT()).num();
    }

    private void createReportData()
    {
        if (!args.caller())
        {
            throw error("This report is implemented in such a way that it must be called from a form.");
        }
 
        MultiSelectionHelper helper = MultiSelectionHelper::createFromCaller(args.caller());
 
        TCI_OutsideServiceImportLog outsideServiceImport = helper.getFirst();

        ttsBegin;
 
        //packingSlipHeader.TCI_OutsideServicePackingSlipId   = NumberSeq::newGetNum(ProdParameters::numRefTCI_OutsideServicePackingSlipEDT()).num();
        packingSlipHeader.TCI_OutsideServicePackingSlipId   = packingSlipId;
        packingSlipHeader.PurchId                           = outsideServiceImport.ResultNumber;
        packingSlipHeader.VendAccount                       = outsideServiceImport.VendAccount;
        packingSlipHeader.TCI_ScanRefNumber                 = outsideServiceImport.TCI_ScanRefNumber;
        packingSlipHeader.insert();
 
        int sequence;

        while (outsideServiceImport.RecId != 0)
        {
            TCI_OutsideServicePackingSlipDetails packingSlipDetails;
 
            packingSlipDetails.TCI_OutsideServicePackingSlipId  = packingSlipHeader.TCI_OutsideServicePackingSlipId;
            packingSlipDetails.Seq                              = sequence;
            packingSlipDetails.ItemId                           = outsideServiceImport.ItemId;
            packingSlipDetails.QtyOrdered                       = outsideServiceImport.Qty;
            packingSlipDetails.insert();
  
            sequence  ;
  
            outsideServiceImport = helper.getNext();
        }
 
        ttsCommit;
    }

    protected void prePromptModifyContract()
    {
        super();

        TCI_OutsideServicePackingSlipContract   contract = this.parmReportContract().parmRdpContract();
        
        contract.parmPackingSlipId(packingSlipId);

    }

}

I have the same question (0)
  • Verified answer
    Anton Venter Profile Picture
    20,635 Super User 2026 Season 1 on at

    Hi,

    Looking at the SrsReportRunController class, I see a run method. That method will only be called if the report should be rendered/created.

    You could create your data before the run is executed by overriding the run method in your class and calling your createReportData method before calling super().

  • Andrew Huisman Profile Picture
    313 on at

    That was it!  Thank you so much!

  • Anton Venter Profile Picture
    20,635 Super User 2026 Season 1 on at

    You are welcome!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 470

#3
Adis Profile Picture

Adis 270 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans