Professional Documents
Culture Documents
To add custom functions (these can only be instance based and not static functions) to
your report go to the report menu and select report properties or right click within the
report design area. Under the code tab write the code you want to include within your
report.
To use this code within the report refer to the Constraints section below.
Constraints
To add a conditional constraint to a particular cell right click on the cell and select
Expression. Alternatively click on the properties dialog box and select the colour cell
option and then select Expression. Here you can write you own constraint and add
parameters to it. The convention for calling the function is:
Code.FunctionName(Parameters)
To create a custom assembly you need to create a new class library WITHIN your
SRS Solution. This can be done in C#, VB.net, J# or any third party language that is
compatible with .net.
On the report menu click report properties or click on the report design area. Select
the references tab:
1. In references, Click Add (…) button and browse to the assembly from the Add
References dialog box.
2. To use your custom code in your assembly in a report expression, you must
call the method of the class.
a. If your method is defined as static. You access it by namespace, class
and method name. E.g. =HealthWare.Employee.CostPerVisit(empID).
b. If the custom assembly contains instance methods you must add the
class and instance name information to the report reference. You
access the method by code member, instance and then method name.
e.g. =Code.rptHealthWare.Employee.CostPerVisit(empID).
2. Next you need to edit the reporting services policy configuration file if your custom
assembly requires permissions in addition to Execution permissions:
Next we add a code group that grants our assembly the additional permissions.
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL
Server\MSSQL\Reporting
Services\ReportServer\bin\Employee.dll"/>
</CodeGroup>
Note : The name of your assembly that you add to the configuration file must match
exactly the name that is added to the RDL under the Code Modules element.
In order to apply custom permissions, you must also assert the permission within your
code. For example, if you want to add read-only access to an XML file
C:\CurrencyRates.xml, you must add the following code to your method:
// C#
FileIOPermission permission = new
FileIOPermission(FileIOPermissionAccess.Read,
@" D:\Temp\EmployeeCost.xml");
try
{
permission.Assert();
For more information, see ".NET Framework Security" in the .NET Framework
Developer's Guide.
Created by: John Ilett
25/05/2011
5 of 6
Crystal report to SRS
Important points:
1. If you modify a custom assembly you must both rebuild and then redeploy it
as the report designer only looks within the report designer folder.
2. System.Data and System.Xml assemblies must be available on both the
computer being used to design the report and the SQL reporting server when
creating a custom assembly
References: