I'm trying to print a report in pdf by code using x++ 2012. The report is the Bank Reconciliation Summary. What I have done by now is this:
#define.ParamCheckingDate ('CheckingDate')
#define.ParamSummary ('ReconciliationSummary')
#define.ParamClearedDetails ('ClearedTransactionDetails')
#define.ParamUnclearedDetails ('UnClearedTransactionDetails')
SrsReportRunController controller = new BankReconciliationSummaryController();
SRSPrintDestinationSettings settings;
BankReconciliationSummaryRdlContract rdlContract;
controller.parmReportName("BankReconciliationSummary.Report");
controller.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
controller.parmShowDialog(false);
rdlContract.setValue(#ParamCheckingDate,mkDate(27,05,2024));
rdlContract.setValue(#ParamClearedDetails,true);
rdlContract.setValue(#ParamSummary,true);
rdlContract.setValue(#ParamUnclearedDetails,false);
controller.parmReportContract().parmRdpContract(rdlContract);
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(@'C:\Users\spineda\Desktop\reporteTest.pdf');
controller.startOperation();
The problem I'm facing right now is that the contract class is private and it doesn't let me set the values of the parms. There is already a way to print the report and I'm trying to replicate that by code. What I want is to set the parameters and the path by code. The process is:
1.I click the print button 2.I fill the parameters and click the Ok button
UPDATE
I found a way to set the values of the parms and now I'm creating the pdf file. The issue that I have now is that I don't want to show the dialog that confirms the params because I'm already setting them by code. Is there a way to set the dialog's visibility off? This is my code:
void clicked()
{
#define.ParamCheckingDate ('CheckingDate')
#define.ParamSummary ('ReconciliationSummary')
#define.ParamClearedDetails ('ClearedTransactionDetails')
#define.ParamUnclearedDetails ('UnClearedTransactionDetails')
SrsReportRunController controller = new BankReconciliationSummaryController();
SRSPrintDestinationSettings settings;
SRSReportParameter checkingDateParam = new SRSReportParameter();
SRSReportParameter clearedTransactionDetailsParam = new SRSReportParameter();
SRSReportParameter reconciliationSummaryParam = new SRSReportParameter();
SRSReportParameter unClearedTransactionDetailsParam = new SRSReportParameter();
SrsReportRdlDataContract rdlContract;
Map reportParametersMap = new Map(Types::String, Types::Class);
Map rdlReportParamMap;
checkingDateParam.name(#ParamCheckingDate);
checkingDateParam.dataType("DateTime");
clearedTransactionDetailsParam.name(#ParamClearedDetails);
clearedTransactionDetailsParam.dataType("Boolean");
reconciliationSummaryParam.name(#ParamSummary);
reconciliationSummaryParam.dataType("Boolean");
unClearedTransactionDetailsParam.name(#ParamUnclearedDetails);
unClearedTransactionDetailsParam.dataType("Boolean");
reportParametersMap.insert("CheckingDate", checkingDateParam);
reportParametersMap.insert("ClearedTransactionDetails", clearedTransactionDetailsParam);
reportParametersMap.insert("ReconciliationSummary", reconciliationSummaryParam);
reportParametersMap.insert("UnClearedTransactionDetails", unClearedTransactionDetailsParam);
rdlReportParamMap = SrsReportRunUtil::createClonedParameters(reportParametersMap);
rdlContract = SrsReportRdlDataContract::newContract("BankReconciliationSummaryRdlContract", rdlReportParamMap);
controller.parmReportName("BankReconciliationSummary.Report");
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
controller.parmShowDialog(false);
rdlContract.setValue(#ParamCheckingDate,DateTimeUtil::newDateTime(mkDate(27,05,2024), 0));
rdlContract.setValue(#ParamClearedDetails,true);
rdlContract.setValue(#ParamSummary,true);
rdlContract.setValue(#ParamUnclearedDetails,false);
controller.parmReportContract().parmRdlContract().setValue(#ParamCheckingDate,DateTimeUtil::newDateTime(mkDate(27,05,2024), 0));
controller.parmReportContract().parmRdlContract().setValue(#ParamClearedDetails,true);
controller.parmReportContract().parmRdlContract().setValue(#ParamSummary,true);
controller.parmReportContract().parmRdlContract().setValue(#ParamUnclearedDetails,false);
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(@'C:\Users\spineda\Desktop\reporteTestExitoso.pdf');
controller.startOperation();
}
Why can't you set the values? The code below works for me -
rdlContract = controller.getDataContractObject(); // Add this line
rdlContract.setValue(#ParamCheckingDate, myDateTime);
rdlContract.setValue(#ParamClearedDetails,true);
rdlContract.setValue(#ParamSummary,true);
rdlContract.setValue(#ParamUnclearedDetails,false);
// controller.parmReportContract().parmRdpContract(rdlContract); // Comment out
Oddly enough though, I had to tweak \C\BankReconciliationSummaryUIBuilder\getParameterSavedValues
because of an issue with how date
/utcDateTime
were getting stored/converted.