The expression contains undefined function call ... calling user functions from a report group passing aggregate functions

5 posts, 1 answers
  1. kellyroberts
    kellyroberts avatar
    45 posts
    Member since:
    Jul 2007

    Posted 27 Oct 2011 Link to this post

    Hi All - I know there have been other threads on this but OIY! this problem is a pain.  I am trying to get a grip on the issue with passing incorrect datatypes to user defined functions thus generating this error.

    I have a simple test function

     

     

    public static decimal hellodecimal(decimal arg1) { return arg1; }

     


    doesnt get any more simple eh?

    When I call this function from the detail section on a report it works well

    =hellodecimal(Fields.SomeDecimalField)

    BUT

    If I call this from a group section and include an aggregate function, like ...

    =hellodecimal(Sum(Fields.SomeDecimalField))

    THEN I get the error  "The expression contains undefined function call hellodecimal()"

    So it seems like "=Fields.SomeDecimalField"  and "=Sum(Fields.SomeDecimalField)" return different data types, is this true?
  2. Answer
    Patrick
    Patrick avatar
    52 posts
    Member since:
    Jun 2010

    Posted 27 Oct 2011 Link to this post

    I've run into this issue before. IIRC, when using aggregates; i.e. Sum(), etc., the arguments are expected to be a double datatype. You have 2-options:

    1. Rewrite the function to accept doubles, vs. decimals
    2. Write an overload that accepts doubles

    My preference would be #2.

    Hope that helps...

    --Patrick

  3. DevCraft banner
  4. kellyroberts
    kellyroberts avatar
    45 posts
    Member since:
    Jul 2007

    Posted 27 Oct 2011 Link to this post

    Hi Patrick - Thanks for the help.  Good Info.  At first I didnt know what datatype the Sum() function would return so I wrote overloads with different data types until it stopped bombing out ... which happened to be,  as you noted below, when I changed the params to double.
  5. Massimiliano Bassili
    Massimiliano Bassili avatar
    323 posts
    Member since:
    May 2006

    Posted 28 Oct 2011 Link to this post

    It just so happened the most precise expression data type in your case is double. This is what the documentation says for return type: Aggregate Functions.

    Cheers
  6. Joie
    Joie avatar
    1 posts
    Member since:
    Nov 2010

    Posted 16 Apr 2013 Link to this post

    Thanks Patrick!
Back to Top
DevCraft banner