Select report design at run time depending on the value of dynamic parameter ?

Hi all Experts

I have a small issue i am facing, there is a report ledger journal report, i have made design for each journal type and using controller class i am controlling the designs and it works fine when it is run from payment journals but when i run it from reports journals —> print journal it does not give me the same result and only returning one designed which i assigned for the journal type= Daily .

so the question is how can i control that at run-time , lets says if i change the journal type at run time it should give me the designed assigned.

any help in this regard will be highly appreciated

regards

In which method you have written the code to control the design?

in main method

Try by having your code in \Classes\LedgerJournalController\preRunModifyContract

this is code for main method

i tried it in prerunmodifycontract but it gives me an error

Report name is not set. Please set report name using parmReportName method.

public static void main(Args _args)
{
LedgerJournalController controller = new LedgerJournalController();

/////// my code start ///////
LedgerJournalTable ledgerJournaltable;
SRSCatalogItemName reportName1;
;
ledgerJournaltable = _args.record();

if(ledgerJournaltable.JournalName == ‘RTHO.’ || ledgerJournaltable.JournalName == ‘RTAZ.’|| ledgerJournaltable.JournalName==‘RTFD.’
|| ledgerJournaltable.JournalName==‘RTGA.’ || ledgerJournalTable.JournalName==‘RTGT.’ || ledgerJournalTable.JournalName==‘RTH1.’
|| ledgerJournaltable.JournalName==‘RTH2.’ || ledgerJournaltable.JournalName==‘RTH3.’ || ledgerJournaltable.JournalName==‘RTHD.’
|| ledgerJournalTable.JournalName==‘RTHO.’ || ledgerJournaltable.JournalName == ‘RTKO.’|| ledgerJournaltable.JournalName == ‘RTLZ.’
|| ledgerJournaltable.JournalName == ‘RTMN.’ || ledgerJournaltable.JournalName == ‘RTMN.’|| ledgerJournaltable.JournalName == ‘RTOK.’
|| ledgerJournaltable.JournalName == ‘RTPR.’ || ledgerJournaltable.JournalName == ‘RTRP.’|| ledgerJournaltable.JournalName == ‘RTRY.’
|| ledgerJournaltable.JournalName == ‘RTSG.’ || ledgerJournaltable.JournalName == ‘RTSK.’|| ledgerJournaltable.JournalName == ‘RTF.’
|| ledgerJournaltable.JournalName == ‘RTFM.’ || ledgerJournaltable.JournalName == ‘RTHZ.’|| ledgerJournaltable.JournalName == ‘RTLL.’
|| ledgerJournaltable.JournalName == ‘RTPH.’ || ledgerJournaltable.JournalName == ‘RTC.’ || ledgerJournaltable.JournalName == ‘RTP.’)
{
reportName1 = ‘LedgerJournal.Report1’;
}
else if(ledgerJournaltable.JournalType==LedgerJournalType::VendInvoiceRegister)
{
reportName1 = ‘LedgerJournal.Invoice’;
}
else if(ledgerJournaltable.JournalType==LedgerJournalType::Payment)
{
reportName1 = ‘LedgerJournal.Payment’;
}
else if(ledgerJournaltable.JournalType==LedgerJournalType::Daily)
{
reportName1 = ‘LedgerJournal.Daily’;
}
else if(ledgerJournaltable.JournalType==LedgerJournalType::Assets)
{
reportName1 = ‘LedgerJournal.Fixasset’;
}
else
{
reportName1 = ‘LedgerJournal.report’;
}
controller.parmReportName(reportName1);

/////// my code end ///////
///
// controller.parmReportName(ssrsReportStr(LedgerJournal, Report));
controller.parmArgs(_args);
controller.setRange(_args, controller.parmReportContract().parmQueryContracts().lookup(controller.getFirstQueryContractKey()));

if (controller.prompt())
{
controller.run();
}
}

What code you have written in prerunModifyContract method?

this.parmReportContract().parmReportName(“Name here”); You can use this to set report name

You will not be having a record when the record is called directly.

You need to get the journal type from the ranges added to the report query.

but how to get the journal type from the ranges added to the report query ?

query = this.getFirstQuery();

queryBuildRange = query.dataSourceTable(tableNum(LedgerJournalTable)).findRange(fieldNum(LedgerJournalTable, JournalType));

if (queryBuildRange)
{
journalType = queryBuildRange.value();
}