Page 1 of 1

Custom Aggregate Function

Posted: Thu May 07, 2020 12:36 pm
by ivar
Hello,

I have registered a custom aggregate function using:

Code: Select all

StiOptions.Services.AggregateFunctions.Add(new SumMoneyFunctionService());
This aggregate function doesn't work when the report calculation mode is 'Interpretation'

Is there a way to make it work?

Regards, Ivar

Re: Custom Aggregate Function

Posted: Mon May 11, 2020 7:05 am
by Lech Kulikowski
Hello,

Please try to use the following code for adding custom functions:

Code: Select all

public class MyFunction
{
    private const string Category = "MyFuncCategory";

    public static string MyFunc(string value)
    {
        return value.ToUpper();
    }

    public static void RegisterFunctions()
    {
        var ParamNames = new string[1];
        var ParamTypes = new Type[1];
        var ParamDescriptions = new string[1];

        ParamNames[0] = "value";
        ParamDescriptions[0] = "Descriptions";
        ParamTypes[0] = typeof(string);

        Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
                                 typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
    }
}
Thank you.

Re: Custom Aggregate Function

Posted: Mon May 11, 2020 7:42 am
by ivar
Thanks,

I used that to add custom functions for expressions and it works.

But how do I add a function to sum multiple lines like in the screenshot?

Regards, Ivar

Re: Custom Aggregate Function

Posted: Tue May 12, 2020 9:27 pm
by HighAley
Hello,

Sorry, there is no way to do this.
Different report events are used for the calculations.
You could use the events to make your calculations.

Thank you.

Re: Custom Aggregate Function

Posted: Thu May 14, 2020 10:09 am
by ivar
ok, not really what I wanted to hear but thanks anyway.

Re: Custom Aggregate Function

Posted: Thu May 14, 2020 12:23 pm
by HighAley
Hello.

Anyway you have to add code to report events and there is no way to get it using the custom function.
As a way you could try to do it in our source code. It's available for purchase.

Thank you.

Re: Custom Aggregate Function

Posted: Thu May 14, 2020 6:03 pm
by ivar
I'll see what I can achieve with the report events. The problem is that many reports would need this custom code and our customers wouldn't know how to edit them without breaking the report. But I can solve it by calculating the totals in the businessobjects beforehand so I have a workaround.

Source code is not really an option I'm afraid. As soon as we start adding our own code we have to maintain it. I already have thousands of lines of code to maintain. I rather use the library as-is as long as most of what we want to achieve is possible.

Thanks for the information.

Re: Custom Aggregate Function

Posted: Tue May 19, 2020 6:59 am
by Lech Kulikowski
Hello

Ok.
Please let us know if you need any additional help.

Thank you.