BLOG

Explore our fascinating news.

This Articles explains how Custom Code created and how to call, deploy and Test our custom function.

In SQL Server Reporting Services (SSRS), we can use custom code to extend the functionality and flexibility of our reports. Custom code allows us to write and incorporate our own functions and expressions into the report definition.

How to Define Custom Code:

Before starting, we must understand where to write custom code in SSRS

  1. Open SSRS report in Visual Studio.
  2. Go to the Report menu and select "Report Properties."
  3. In the "Report Properties" dialog, navigate to the "Code" tab.
  4. Write the custom code in the code editor. The code must be written in VB.NET or C#.
Customized Functions:

In the code editor, we can define custom functions that perform specific calculations or operations.

For example, we can write a function to calculate a custom aggregate or perform complex data manipulation.

Ensure that our custom functions have a valid return type and parameters, as required.

Call Custom Code from Expressions:

In our report design, we can reference and call the custom code functions from expressions.

Select the report item (textbox, table cell, etc.) where we want to use the custom code.

In the Properties pane, locate the "Expression" property and click on the ellipsis button (...) to open the expression editor.

In the expression editor, we can call our custom code functions using the syntax:

= Code.FunctionName (Parameters).

Provide the necessary parameters as required by custom function.

Deploy and Test:

After writing the custom code and incorporating it into our report, deploy the report to the SSRS server or preview it locally.

Test the report to ensure that the custom code functions are executing correctly and providing the desired results.

It's important to note the following considerations when using custom code in SSRS:
  1. Custom code is report-specific and cannot be shared across multiple reports.
  2. Custom code is executed within the report processing scope and can only be used within the report's expressions.
  3. The custom code may have an impact on report performance, especially if complex calculations or operations are involved.
  4. 4.By leveraging custom code in SSRS, we can extend the capabilities of our reports beyond the built-in functions and expressions, allowing for more complex calculations and data manipulation.