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); } }
You are welcome!
That was it! Thank you so much!
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().
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156