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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

odd behaviour with a custom SSRS report

(0) ShareShare
ReportReport
Posted on by 427

Hello everyone,

I've modified the cheque printing so it will spawn an extra report after printing the cheques. This new report uses the same tmpChequePrintout as its basis. I have actually copied the ChequeController/ChequeDP to perform the similar report initiliazing. The new report is always launched right after printing the cheques.

What's happening is the following:

1) output to screen works fine; new report is shown and layout is correct

2) printing to either a PDF printer or the physical printer only works right after restarting the AOS; it will never work afterwards

2.1) but the layout is a mess and  single page is spreaded across 12 pages!

3) trying to run the report afterwards will produce nothing when sending to the PDF printer (no error when tracing code) and will report the infamous "Settings to access printer 'PRTRXADM01 on impression (redirected)' are not valid."

If I can throw some technical details to enhance my chance of getting help, the programming I have done is as follow:

In the BankChequePrint class, method printDocument, after the cheques are printed, I call the new report:

case ChequeFormType::CAStyle :

this.runReport(menuitemoutputstr(Cheque_CA));

//new report not working

this.runReport(menuitemOutputStr(NewReportName));

// launching the ledgerJournal does however work

this.runReport(menuitemOutputStr(LedgerJournal));

BankChequePrint holds the temporary cheque table, tmpChequePrintout. Since this table contains what I need, I have duplicated the ChequeController class for the new report

class NewReportController extends SrsReportController

in the init method, I grab the bankChequePrint object:

bankChequePrint = caller;

The base framework will call the preRunModifyContract which will marshall the tmpChequePrintout to send it to the NewReportDP object.

protected void preRunModifyContract()

{

SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;

// get the Temp table, and marshall it across to SSRS

new SRSReportRunPermission().assert();

contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(tmpChequePrintout));

// set the print destination in contract

if(printDestinationSetting)

{

this.parmReportContract().parmPrintSettings(printDestinationSetting);

}

}

The data provider class is extending from SrsReportDataProviderPreProcessTempDB and it has the following predefined contract:

[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]

Debugging the execution show no problem in passing the tmpChequePrintout table from the controller to the data provider. In the SRSProxy class, in the renderReportToPrinter, this line is where everything fails when sending to the network printer (and does nothing when printing to the PDF printer, success returns true!):

success = proxyObject.PrintReportWithPageSettings(reportPath,parameterValueArray,printerName,overridePrintContractSettings,deviceInfo,numberOfCopies,overridePaperSettings,pageSettings);

Thanks in advance for any suggestions,

Eric

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,726 Most Valuable Professional on at

    I think you're trying to test too many things at once and then you have no idea which part is wrong.

    Forget the integration to BankChequePrint for a moment and first try to run your report directly. Check how it behaves, such as whether print to PDF works as expected.

    If it doesn't work, you see that you all the other things aren't relevant to the problem and your testing becomes easier and more focused.

    If it works, you at least ruled out several potential causes and you can focus on your other code.

  • Konrad U Profile Picture
    804 on at

    There is a lot going on but a few comments.

    1. SSRS is an old beast, difficult to use, picky, erratic. Having reports look fine on screen and not print correctly is its reason to exist.

    2. The calls above are done through dlls. Checking the dll levels might show a problem. Typically the different dlls have different parameters.

    I agree that breaking the debugging down into separate steps is a good solution. For example getting it to render correctly first. Then tackle the dll based issues with memory and parameters.

    Finally check for hotfixes.

  • Arkadia2 Profile Picture
    427 on at

    Hello Crispin,

    Many thanks for taking the time to reply. You got it right for the layout problems; settings all fields that had true in their "CanGrow" property fix the layout spreading itself on 12 pages; at least when printing to the PDF printer. I assume it will be the same on the network printer, I will check this tomorrow as I'm working from home today.

    However...

    The report still only runs the first time after restarting the aos service. The second time around, pdf will produce nothing and printer will return the error message ("settings to access printer are not valid"). Really weird situation. Which still make me thinks I got a memory corruption going on.

  • Arkadia2 Profile Picture
    427 on at

    Hello Konrad,

    Thanks for answering my question #1... it also made me laugh, which is good considering the mood I was when leaving the office friday evening! With Crispin pointer, I managed to get the layout fixed. Still has the incoherent running issue which makes the report run correctly only once... then it requires the server aos restart!

    My dev vm is also the server, don't know what good this detail holds however. AX cu 8 on Windows 10 enterprise.

  • Arkadia2 Profile Picture
    427 on at

    Hello Martin,

    I am sorry as I may have thrown too many details in my post. I thought being more precise on the code stucture would help clarify the situation. Crispin tips have helped me to figure out the layout issue and I got an explanation from Konrad for the report being rendered correctly on screen while coming out completely whacked out on a printer.

    Now it remains that the cheque annex (the purpose of the new report) is only printed once. It needs the server aos to be restarted otherwise it won't print again!

  • Arkadia2 Profile Picture
    427 on at

    Hi Crispin,

    I don't think the printer is the problem, this new report is the only one not working correctly. Plus it behaves oddly on the PDF printer as well. And it is also my first SSRs report, so obviously I made a mistake elsewhere (apart from the layout correction you pointed to me.

    (yeah, I've managed to stay away all those years from SSRS but now it is catching up with me!)

    Regards,

    Eric

  • Konrad U Profile Picture
    804 on at

    Eric,

    Glad you got the rendering figured out. In some cases we just elected to output as Excel which allows users to work with the results.  For heavily formatted reports we still use Bottomline or migrate the AX 2009 report to 2012 r3. Thankfully they don't take too much to get running.

    Still not sure why Microsoft chose SSRS. About 80% of the total conversion cost was redoing reports or recreating those that Microsoft deleted. In particular the one that caused us the most problem was the open accounts receivable statements. In 2009 it printed as one report which Bottomline formatted well. In 2012 it printed separate reports for each customer which became extremely difficult for users to handle, not to mention archive.

  • dynamics developer Profile Picture
    2 on at

    Since you are printing multiple reports, when you print the second time only the new report shows up blank or the standard one also?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
Nagendra Varma K Profile Picture

Nagendra Varma K 4

#2
Harisgillani Profile Picture

Harisgillani 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans