Data Dynamics Reports Online Help
Custom Code
See Also Support Forum
User Guide > Creating Reports > Building Reports > Expressions > Functions > Custom Code

Glossary Item Box

You can use custom code in your expressions to further extend the capabilities of Data Dynamics Reports. For complex functions, or those you will use many times in your report, embed the code in the report. For code that you will use in many different reports, maintain the code in a custom assembly and refer to its methods in your expressions.

Embedded Code

You can add code to your report on the Code tab.
 

You must use instance-based Visual Basic .NET code in the form of a code block. You can include multiple methods in your code block, and access those methods from expressions in report item properties.

Here is a simple example of a single method code block:

Public Function GetDueDate() as Date
  Return DateTime.Now.AddDays(30)
End Function

Here is the expression used to call the method in the above code block:

=Code.GetDueDate()

Custom Assemblies

You can create custom assemblies in C# or Visual Basic .NET to call from your reports. To make code available to multiple reports:

  1. Create or find the assembly you wish to use.
  2. Make the assembly available to the report engine.
    • If you are embedding the designer or viewer controls in your own application, copy the assembly to the same location as your executable.
    • If you are using the included designer or viewer, copy the assembly into the Data Dynamics Reports Assemblies folder (C:\Program Files\Data Dynamics\Reports\Build Number\Assemblies).
      Note: To make the assembly available for use in your own application and for use in designing reports for your application, copy it to both locations listed above. Or you can place the assembly in the Global Assembly Cache (C:\Windows\Assembly).
  3. Add an assembly reference to the report.
    • From the Report menu, choose Report Properties.
    • On the References page, add your assembly.
  4. Access the assembly through expressions.
    • To access static members (member denoted as public static in C# assemblies, or as Public Shared in Visual Basic assemblies):
      • =Namespace.Class.Member
    • To access class instances (see Creating an Instance Method):
      • =Code.InstanceName

See Also

Tutorials
Adding Code

©2010. GrapeCity, inc. All Rights Reserved.