Extending Report Designer with user function

4 posts, 0 answers
  1. Michele
    Michele avatar
    5 posts
    Member since:
    Jan 2014

    Posted 06 Jun 2014 Link to this post

    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



























  2. Peter
    Admin
    Peter avatar
    1665 posts

    Posted 09 Jun 2014 Link to this post

    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.

     
  3. Bjorn
    Bjorn avatar
    2 posts
    Member since:
    May 2014

    Posted 05 Jul in reply to Michele Link to this post

    Hey Michele, did you ever solve this? I'm having exactly the same problem and can't figure out how to solve it...
  4. Neli
    Admin
    Neli avatar
    190 posts

    Posted 10 Jul Link to this post

    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
Back to Top