Create a simple report in D365Fo and learn the process how SSRS reports works?
Whenever we deal with implementation project of Dynamics 365 Finance and operations we always need to develop reports which shows information from multiple tables or single table. The reason it is asked is because standard Dynamics reports are not available. This requirement comes under gap.
To design a report we need to follow below 8 steps
1.? ?Create a Data contract class
2.? ?Create a Data provider class
3.? ?Create a Temporary table
4.? ?Design a report
5.? ?Create a controller class
6.? ?Create a Menu item
7.? ?Create a Menu
8.? ?Create a Security role
Detailed steps for the report designing as follows:
Follow the steps to create project for D365Fo in this blog?Create a new project
Step1. How to create a Data contract class?
Create a Class SSRSReportContract, basically this is contract class which is used for filters on first report screen.
To create a contract class , follow below screen and then add the below code.
Code for the contract class.
[DataContractAttribute]
class SSRSReportContract
{
PaymTermId paymTermId;
[DataMemberAttribute('PaymTermId')]
public PaymTermId parmPaymTermId(PaymTermId _paymTermId = paymTermId)
{
paymTermId = _paymTermId;
return paymTermId;
}
}
Step 2. Create a temporary table
Add desired fields in reports with ENUM data types as these can be easily extended or directly pull fields from AOT. Add Index and filed groups if needed.
Step 3.? Create a Data Provider Class, basically this class is used to add the logic for our main table on which report is based upon.
Code:
[SRSReportParameterAttribute(classStr(SSRSReportContract))]
class SSRSReportDataProvider extends SRSReportDataProviderBase
{
SSRSReportTmp reportTmp;
[SRSReportDataSetAttribute(tableStr(SSRSReportTmp))]
public SSRSReportTmp getTmp()
{
select reportTmp;
return reportTmp;
}
public void processReport()
{
SSRSReportContract contract =
this.parmDataContract() as SSRSReportContract;
CustGroup custGroup;
PaymTermId paymTermId = contract.parmPaymTermId();
while select custGroup
where custGroup.PaymTermId == paymTermId
{
reportTmp.clear();
reportTmp.CustGroupId = custGroup.CustGroup;
reportTmp.Name = custGroup.Name;
reportTmp.PaymTermId = custGroup.PaymTermId;
reportTmp.ClearingPeriod = custGroup.ClearingPeriod;
reportTmp.insert();
}
}
}
Step 4. Now add report Datatype via Add New Item option.
4.a Add a new Dataset.
4.b Right click on properties of New Data Set. There are 3 options, select either of the 1 depending on your requirement.
1. Query :- If you want to show report via Query dataset.
2. Report Data Provider :- If report is based on tables.
领英推荐
3. AX Enum Provider :- If report is based on Enum.
https://d365webgroups.blogspot.com/2024/08/create-simple-report-in-d365fo-for.htmlWe will select the report data provider as SSRSREPORTDATAPROVIDER class created earlier. Please note if class is not in list then build and then try to select.
Select the 3 dots in query object and select all fields in the next screen.
Now add the report design. Use Precision Design to design report by self and Auto design for system to create a base design.
Now Double click on the report Design under Design node and below screen will open.
Once Design is completed , Deploy the report. In case Deployment is not completed in VS then use powershell script. Link for Powershell script deploy-ssrs-reports-using-powershell-d365-fo-shayan-arshi I have personally used by running powershell in Admin mode.
C:\AOSService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation
Step 5: Create a new controller class steps are mentioned above. Write code as below in screenshot, this controller class is used to run the report.
Enter the below code:
class SSRSReportController extends SrsReportRunController
{
public static SSRSReportController construct()
{
return new SSRSReportController();
}
public static void main(Args _args)
{
SSRSReportController controller = SSRSReportController::construct();
controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(SSRSReport,PrecisionDesign1));
controller.startOperation();
}
}
Step 6: Create a new Output menu item to attach report at the front end.
Add the following properties to output menu item.
Step 7. Create a new Menu Extension and then add the menu item.
I have added menu item under Inquiries and report, you can add as per your need.
Step 8. Create a new security role for report which I will cover in next blog. We can now see the report after build is completed as below:
When we run the report Payment Term field is available for selection.
I wish this blog will help someone to learn and grow in Dynamics 365 Finance and Operations domain as technical consultant, if anything is missed or any feedback is most welcome.
Thanks for your time.??????
Dynamics 365 F&O Technical Consultant |D365ERP|X++|SQL | SSRS
7 个月Very informative