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

Undefined Function - Integer Parameter

4 Answers 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 17 Nov 2013, 05:23 AM
I'm having trouble passing an integer parameter to a user defined function. I've read all of the posts and the kb article, but I can't seem to pass an interger to my function. I can pass a string, but not an integer. 

Here's what I've got:

public static string GetInt(int orgId)
{
    return "Get Int: " + orgId.ToString();
}
 
public static string GetText(string orgId)
{
    return "Get Text: " + orgId;
}

My binding expressions are:

= GetText(Parameters.ParmString.Value)

= GetInt(Parameters.ParmInt.Value)

Integer Parameter: AllowBlank: True, AllowNull: False, MultiValue: False, Type: Integer, Value: 9999

String Parameter: AllowBlank: True, AllowNull: False, MultiValue: False, Type: String, Value: Test String


Thanks. All help is appreciated.

4 Answers, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 20 Nov 2013, 01:07 PM
Hi,

As stated in this documentation article, the integer parameter values are internally converted to Int64 in order to accommodate large numbers. That's why your function throws an exception - it expects a 32-bit integer.

If you are not sure what is the type of a function parameter, the easiest way to detect it is to create a small function that accepts an object as a parameter and then use GetType() to see what type it is actually:
public static string GetParameterValueType(object parameterValue)
{
    if (parameterValue == null)
        return "null";
      
    return parameterValue.GetType().FullName;
}

Regards,
Ivan Hristov
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
G-Man
Top achievements
Rank 1
answered on 21 Nov 2013, 08:49 PM
Hi,

I had the same problem where the function that expected an int was never called by the binding.  Going off the article that was posted by Ivan, you have to set the parameter to an Int64 type and that should work.

public static string GetInt(Int64 orgId)
{
    return "Get Int: " + orgId.ToString();
}

I hope that helps.
0
Tim
Top achievements
Rank 1
answered on 22 Nov 2013, 01:49 PM
Thanks for the help. Int64 worked.

I think it would be beneficial if the documentation on user functions, http://www.telerik.com/help/reporting/expressions-user-functions.html  referenced the API documentation, http://www.telerik.com/help/reporting/t_telerik_reporting_reportparametertype.html. The only example they give is a string parameter which is pretty straight forward.
 
0
Ivan Hristov
Telerik team
answered on 26 Nov 2013, 04:26 PM
Hello Tim,

We're glad you managed to resolve the problem.

Thank you for your feedback. It is important to us to know where the documentation lacks completeness and which articles need to be explained thoroughly. Generally your user function would work if you pass an integer parameter to it, so the User Functions article is precise. Besides, the Report Parameters article includes a link to the report parameter type enumeration

However, targeting more complete examples coverage, we would add your case as an example showing how to pass an integer report parameter to an user function and explain why it should be handled as an Int64 instance.

Regards,
Ivan Hristov
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Tim
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
G-Man
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Share this question
or