This is a migrated thread and some comments may be shown as answers.

Extending Report Designer with user function

4 Answers 254 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 1
Michele asked on 06 Jun 2014, 06:48 AM
Hi,
I'm having trouble extending Report Designer with User Function.

I've created an assembly with 3 functions the following code:

using System;
using Telerik.Reporting.Expressions;


namespace ReportLib
{
    public static class SVFunctions
    {
        [Function(Category = "My Functions", Namespace = "ReportLib", Description = "Duration")]


        public static string Duration(DateTime Start, DateTime End)
        {
            TimeSpan ts = End- Start;
            double Ore = ts.TotalHours;
            double Minuti = ts.TotalMinutes - (Ore*60);
            double Secondi = ts.TotalSeconds - (Ore*60) - (Minuti*60);
            return string.Format("{0:0}:{1:0}:{2:0}", Ore, Minuti, Secondi);


        }

        [Function(Category = "My Functions", Namespace = "ReportLib", Description = "ToLocalTime")]
        public static DateTime ToLocalTime(DateTime utc)
        {
            return utc.ToLocalTime();
        }


        [Function(Category = "My Functions", Namespace = "ReportLib", Description = "Adesso")]
        public static string Adesso()
        {
            return "12/12/2014";
        }
   }

I've added the reference of the assembly inside the ReportDesigner config file.

<Telerik.Reporting>
     <AssemblyReferences>
         <add name="ReportLib" version="1.0.0.0" />
     </AssemblyReferences>
</Telerik.Reporting>



I've created a report and with a text field using an expression that references to the function Adesso() as you can see in to the attached picture.

When I run the report I've the following error (shown into the picture)
An error was occurred while processing TexBox 'xxx'. The Expression contains object 'ReportLib' that is not defined in the current context.

What's I'm doing wrong

Michele



























4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 09 Jun 2014, 07:27 AM
Hi Michele,

Please check out the Deploying trdx (XML report definition) that uses external assembly KB article, that elaborates on the required configuration.

Regards,
Peter
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Bjorn
Top achievements
Rank 2
answered on 05 Jul 2019, 02:09 PM
Hey Michele, did you ever solve this? I'm having exactly the same problem and can't figure out how to solve it...
0
Neli
Telerik team
answered on 10 Jul 2019, 11:17 AM
Hi Bjorn,

Let me explain the necessary steps briefly:
1. Create a new Class Library and implement your custom function.
2. Build the project.
3. Navigate to the bin folder of the project and copy the dll file.
4. Go to the installation folder of Telerik Reporting Designer C:\Program Files (x86)\Progress\Telerik Reporting [Version]\Report Designer and paste the dll file.
(for example: C:\Program Files (x86)\Progress\Telerik Reporting R2 2019\Report Designer)
5. Open Telerik.ReportDesigner.exe.config file through a text editor to register the copied assemblies. For example:
<Telerik.Reporting>
   <AssemblyReferences>
     <add name="MyUserFunction" version="1.0.0.0" culture="neutral" publicKeyToken="null" />
   </AssemblyReferences>
</Telerik.Reporting>

For additional information, refer to Extending Report Designer article  and How to use external assemblies with custom user functions in the Report Designer KB article.

Regards,
Neli
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Brandon
Top achievements
Rank 1
Iron
answered on 26 Oct 2021, 03:47 PM

I was having the exact same problem and was able to resolve it by doing the following:

1. Inherit Telerik.Reporting.Report class

2. Change the class to be non-static but leave the method as static.

Here's my example:

public class ParseHtml : Telerik.Reporting.Report
    {
        [Function(Category = "Html", Namespace = "ParseHtml",
          Description = "Removes the <meta> tag from an HTML string")]
        public static string RemoveMetaTag(string markup)
        {//Method logic goes here}

}

 

Hopefully this helps anyone in the future.

Tags
Report Designer (standalone)
Asked by
Michele
Top achievements
Rank 1
Answers by
Peter
Telerik team
Bjorn
Top achievements
Rank 2
Neli
Telerik team
Brandon
Top achievements
Rank 1
Iron
Share this question
or