Writing and deploying a custom report in Visual Studio for Dynamics 365 /PowerApps
Sometimes, we need to develop complex reports, for example, reports that involve more than one related entity or where we need to use expressions (we can use expressions in reports to define the content of SSRS controls) to validate the value of a field. These types of reports are not possible to develop using the Report Wizard, so we use Visual Studio to develop them. In order to write custom reports in Visual Studio, we need to make sure SQL Data Tools is installed with the Report Authoring Extension for Dynamics 365 CE. The Report Authoring Extension is needed for writing FetchXML reports.
We can use the following steps to write a report using Visual Studio; here, we are using Visual Studio 2012 SQL Data Tools:
- Start SQL Server Data Tools for Visual Studio 2012 and follow the steps shown in the following screenshot to create the project:
- Once the project is created, we can right-click on the Reports folder under Solution Explorer to Add a new report, as follows:
- Right-click on Data Sources from Report Data and select Add Data Source.
- If we want to connect to Dynamics 365 CE Online, we can use the following connection details:
Here, you can see that, under Connection string, we have provided the organization URL only. Currently, we only have one organization in our tenant but, if you have multiple organizations, then you need to mention the organization name after the URL, as follows:
https://himbapauto.crm8.dynamics.com;HIMBAPAutoDev;
In the preceding connection string, we are connecting to our HIMBAP Auto Dev organization only.
- Next, click on Credentials and enter your Dynamics 365 CE credentials, which you use to connect with your Dynamics 365 CE organization:
- If you are working in a Dynamics 365 CE on-premises environment, you can set up a connection with your Dynamics 365 CE on-premises by clicking on the Edit... button to set up a connection string:
- Once we have our data source created, we need to set up a dataset where we will connect to our entity. To create a dataset, we need to add a FetchXML query. As mentioned earlier, we can get FetchXML from ADVANCED FIND or we can create it using XrmToolBox.
- Open ADVANCED FIND, select an entity, add the required field, and then click on the Download Fetch XML button:
This will download the FetchXML query for this view. We can open the downloaded file and copy the query for use in the dataset.
- Go to our report project, right-click on Datasets and select Add Data Set. After that, we configure it by following the steps shown in the screenshot:
- After clicking on the OK button, it will connect to Dynamics 365 CE and will show all the fields of this entity, which we can use in the Report Designer area, as follows:
- Let's first add a table to display the entity information. Click on the Toolbox view form on the left-hand side and drag a table control over the Report Designer. Click on the first column in the data row and then let's select him_vehiclename to display under it:
- We can add more columns to the table by taking the following steps:
We can remove or hide columns using the Delete Columns and Column Visibility... options. We can also increase the column width by simply expanding the column width up to the required width.
- Let's add the following fields and change their labels as follows:
Display name | Logical name |
Vehicle | [him_vehiclename] |
Vehicle Number | [him_vehiclenumber] |
Make | [him_make] |
Model | [him_model] |
Category | [him_vehiclecategory] |
Type | [him_vehicletype] |
We can select the field and use formatting toolbars to format columns based on our requirements.
- Click on the Preview button. You should be able to see all the vehicle data in your report.
- Build a report project so that you can upload it to Dynamics 365 CE.
Deploying a report
To upload a report, we can take the following steps:
- Navigate to the Reports area and click on the New button.
- Click on the Choose File button to look for RDL:
Once the file is uploaded, click on Save to save our file. Now we can click on the Run report button to run our report and it will show the data for the vehicle entity. Now, let's modify our report and add more options, such as adding grouping and a parameter to filter the report.
posted on 2021-07-13 17:54 lingdanglfw 阅读(60) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?