87) Create a Query based SSRS Report and pass the current buffer using controller class
I had a scenario where I need to create a query based report and pass the current record to filter the report.
Step 1:- Create a query and create a design of it
==========================================================================
Step 2 :- Create a controller class to identify the current form name and pass the range in it
// <summary>
/// The <c>AvaFieldWorkOrderController</c> class is the controller class for the <c>AvaFieldWorkOrderQueryReport</c> SSRS report.
/// </summary>
public class AvaFieldWorkOrderController extends SrsReportRunController
{
EntAssetWorkOrderTable workOrderTable;
/// <summary>
/// Gets the report controller query.
/// </summary>
/// <returns>
/// The report controller query.
/// </returns>
public Query getQuery()
{
return this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey());
}
protected void prePromptModifyContract()
{
//EntAssetWorkOrderTable workOrderTable;
CompanyImage companyImage;
Query query;
QueryBuildDataSource ds;
QueryBuildRange range;
super();
if (this.parmArgs().record())
{
workOrderTable = this.parmArgs().record() as EntAssetWorkOrderTable;
if (workOrderTable)
{
query = this.getQuery();
ds = query.dataSourceTable(tableNum(AvaFieldWorkOrderReportView));
ds.clearRanges();
range = SysQuery::findOrCreateRange(ds, fieldNum(AvaFieldWorkOrderReportView, WorkOrderId));
range.value(SysQuery::value(workOrderTable.WorkOrderId));
}
}
}
public static AvaFieldWorkOrderController construct()
{
return new AvaFieldWorkOrderController();
}
public static void main(Args _args)
{
SRSPrintDestinationSettings settings;
AvaFieldWorkOrderController controller = AvaFieldWorkOrderController::construct();
controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(AvaFieldWorkOrderQueryReport, Report));
// controller.parmReportRun().parmReportContract().parmReportCaption("VINAY");
if (_args.record())
{
controller.parmShowDialog(false);
controller.prePromptModifyContract();
controller.run();
}
else
{
controller.startOperation();
}
}
public LabelType parmDialogCaption(LabelType _dialogCaption = reportDialogCaption)
{
LabelType reportDialogCaptionLoc = super();
// str fileName = this.parmReportContract().parmReportCaption();
this.parmReportContract().parmReportCaption("@AvaTransMountain:AvaFieldWorkOrderReport_Label" + " : " + workOrderTable.WorkOrderId);
return reportDialogCaptionLoc;
}
}
=======================================================================
Step 3 :- create a action menu item and define the controller class and place in the form menu item
Comments
Post a Comment