I have written AIF service to save the invoice report to a specified folder. i pass invoice Id to the service which should save the pdf. The same code which i wrote is working from Job. but when i call the service from C# application i am getting “A call to the Microsoft Dynamics AX SRSFrameworkService service failed. Failed to logon to Microsoft Dynamics AX” error.
Any help is appreciated to solve this problem.
Here is my code in the service method:
private void saveInvoice(FilePath _filePath, InvoiceId _invoiceId)
{
srsprintdestinationsettings settings;
SrsReportRunController controller = new ReceiptController();
FreeTextInvoiceContract rdpcontract = new FreeTextInvoiceContract();
select * from custJour where custJour.InvoiceId == _invoiceId;
controller.parmreportname(ssrsreportstr(FreeTextInvoice,Report));
controller.parmLoadFromSysLastValue(false);
controller.parmshowdialog(false);
rdpcontract.parmCustInvoiceJourRecId(custJour.RecId);
controller.parmReportContract().parmRdpContract(rdpcontract);
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(_filePath);
controller.startOperation();
}