Skip to main content

Notifications

Announcements

No record found.

Creating a simple report with Precision design in D365FO

Hi,

In this post we will see the creation of simple report with precision design in D365FO.

Step1: Created custom tables by name SampleTable and SampleTrans where both tables holds Parent and Child relationship respectively. Field RefId of table SampleTrans holds reference of table SampleTable through field Id. Field Id extends new EDT SampleTableId.

Step2: To display data from these tables, created a report query SSRSReportQuery (namely) and included this tables under it.

Step3: Created a new contract class SSRSReportContract (namely) and included the required dialog fields like Id from SampleTable, StartDate and EndDate as parm methods.

[
DataContractAttribute,
SysOperationDataContractProcessingMode::CreateUIBuilderForRootContractOnly),
SysOperationGroupAttribute('Criteria',"@SYS8815",'1')
]
class SSRSReportContract
{
SampleTableId id;
StartDate startDate;
EndDate endDate;
/// <summary>
/// Gets or sets the value of the datacontract parameter Id.
/// </summary>
/// <param name="_id">
/// The new value of the datacontract parameter Id; optional.
/// </param>
/// <returns>
/// The current value of datacontract parameter Id
/// </returns>
[
DataMemberAttribute('Id'),
SysOperationLabelAttribute(literalstr("Record identifier")),
SysOperationHelpTextAttribute(literalStr("Record identifier of sampletable")),
SysOperationGroupMemberAttribute('Criteria'),
SysOperationDisplayOrderAttribute('1')
]
public SampleTableId parmId(SampleTableId _id = id)
{
id = _id;
return id;
}
/// <summary>
/// Gets or sets the value of the datacontract parameter StartDate.
/// </summary>
/// <param name="_startDate">
/// The new value of the datacontract parameter StartDate; optional.
/// </param>
/// <returns>
/// The current value of datacontract parameter StartDate
/// </returns>
[
DataMemberAttribute('StartDate'),
SysOperationLabelAttribute(literalstr("Start date")),
SysOperationHelpTextAttribute(literalStr("Starting date of the date range considered to process the records")),
SysOperationGroupMemberAttribute('Criteria'),
SysOperationDisplayOrderAttribute('2')
]
public StartDate parmStartDate(StartDate _startDate = startDate)
{
startDate = _startDate;
return startDate;
}
/// <summary>
/// Gets or sets the value of the datacontract parameter EndDate.
/// </summary>
/// <param name="_endDate">
/// The new value of the datacontract parameter EndDate; optional.
/// </param>
/// <returns>
/// The current value of datacontract parameter EndDate
/// </returns>
[
DataMemberAttribute('EndDate'),
SysOperationLabelAttribute(literalstr("End date")),
SysOperationHelpTextAttribute(literalStr("Ending date of the date range considered to process the records")),
SysOperationGroupMemberAttribute('Criteria'),
SysOperationDisplayOrderAttribute('3')
]
public EndDate parmEndDate(EndDate _endDate = endDate)
{
endDate = _endDate;
return endDate;
}
}

Step 4: Created a temporary table  SSRSReportTableTmp (of type TempDB) and included the required fields.

Step 5: Created a dataprovider class SSRSReportDP(namely) that extends SRSReportDataProviderBase class. Added methods to honor the ranges like StartDate, EndDate, Id and inserts data into SSRSReportTableTmp.

/// <summary>
/// The <c>SSRSReportDP</c> class fetches records for the <c>SSRSPrecisionDesignReport</c> report.
/// </summary>
[
SRSReportQueryAttribute(querystr(SSRSReportQuery)),
SRSReportParameterAttribute(classstr(SSRSReportContract))
]
class SSRSReportDP extends SRSReportDataProviderBase
{
SSRSReportTableTmp reportTableTmp;
SampleTable sampleTable;
SampleTrans sampleTrans;
/// <summary>
/// Gets the data for the report from the temporary table.
/// </summary>
/// <returns>
/// The temporary table <c>SSRSReportTableTmp</c>.
/// </returns>
[
SRSReportDataSetAttribute(tablestr(SSRSReportTableTmp))
]
public SSRSReportTableTmp getSSRSReportTableTmp()
{
select reportTableTmp;
return reportTableTmp;
}
/// <summary>
/// Retrieves records based on the parameters entered.
/// </summary>
public void processReport()
{
QueryRun queryRun;
Query query;
QueryBuildDataSource qbdsSampleTable, qbdsSampleTrans;
QueryBuildRange qbrDueDate;
SSRSReportContract contract;
StartDate startDate;
EndDate endDate;
SampleTableId id;

contract = this.parmDataContract() as SSRSReportContract;
id = contract.parmId();
startDate = contract.parmStartDate();
endDate = contract.parmEndDate();
query = this.parmQuery();
qbdsSampleTable = query.dataSourceTable(tableNum(SampleTable));

SysQuery::findOrCreateRange(qbdsSampleTable, fieldNum(SampleTable, Id)).value(queryValue(id));
SysQuery::findOrCreateRange(qbdsSampleTable, fieldNum(SampleTable, DueDate)).value(queryRange(startDate, endDate));
queryRun = new QueryRun(query);
while (queryRun.next())
{
sampleTable = queryRun.get(tablenum(SampleTable));
sampleTrans = queryRun.get(tablenum(SampleTrans));
this.insertSSRSReportTableTmp();
}
}
/// <summary>
/// Inserts records to <c>SSRSReportTableTmp</c> temporary table.
/// </summary>
private void insertSSRSReportTableTmp()
{
reportTableTmp.Id = sampleTable.Id;
reportTableTmp.Name = sampleTable.Name;
reportTableTmp.Amount = sampleTrans.Amount;
reportTableTmp.DueDate = sampleTrans.DueDate;
reportTableTmp.Description = sampleTrans.Description;
reportTableTmp.TransID = sampleTrans.TransID;
reportTableTmp.insert();
reportTableTmp.clear();
}
}
Step 6:  Created a new report SSRSPrecisionDesignReport with precision design.

Step 7:  Added the dataset SSRSReportDP with type as Data Provider class and refreshed the parameters.

Step 8: Added table control onto the body of the report and included the fields from SSRSReportTableTmp table.

Step 9: Inserted Page Header to the body of the report

Step 10: For string based text boxes alignment was set to left and real based text boxes alignment was set to right. Text boxes border was set such that it resembles the standard report.

Step 11: Deployed the report through Visual Studio.

Step 12: Created controller class SSRSReportController(namely) and referred to the design "Report" of report SSRSPrecisionDesignReport

/// <summary>
/// The <c>SSRSReportController</c> class is the controller class for the <c>SSRSReportContract</c> report.
/// </summary>
class SSRSReportController extends SrsReportRunController
{
public static void main(Args _args)
{
SSRSReportController controller = new SSRSReportController();
controller.parmReportName(ssrsReportStr(SSRSPrecisionDesignReport, Report));
controller.parmArgs(_args);
controller.startOperation();
}
}

Step 13: Created a new output menuitem SSRSPrecisionDesignReportMenuItem (namely), referred to the SSRSReportController class and labelled the report as "Custom Report". Added it to SystemAdministration Menu.

Step 14: Generated the report by providing the values for dialog fields Start date as "8/1/2019" , End date as "11/30/2019" and Id as "1" respectively.

 Regards,

Chaitanya Golla

Comments

*This post is locked for comments