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

User Function Error

4 Answers 117 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Projects Computerra
Top achievements
Rank 1
Projects Computerra asked on 19 Jan 2010, 12:39 PM
Hello Everyone,

I am getting below error while calling User defined function in Telerik Report.
I didn't find anything wrong with this code.

"The error has occured while processing TextBox 'textBox1':
This expression contains undefined function call DateLeft().


Please See below code

this

 

.textBox1.Value = "= DateLeft(Fields.DateReleased,EndofMonths(Fields.Month))";

DataType of Fields.DateReleased is System.DateTime
DateType of Fields.Month is System.Int32.  

 

 

 

 

Public static string DateLeft(DateTime ReleasedDate, DateTime EndofMonth)  

{

  string strReturn = "";  

  if ((ReleasedDate == null || ReleasedDate == DateTime.MinValue) ||  (EndofMonth !=  null && EndofMonth != DateTime.MinValue && ReleasedDate > EndofMonth.AddDays(1)))  

         strReturn = "IN JAIL";    

else  

       strReturn = ReleasedDate.ToString("MM/dd/yyyy hh:mm");     

return strReturn;  

 }

EndofMonth is another User defined function that passes as argument of above user defined function 

public static DateTime EndofMonths(int parMonth)  

 { 

   if (parMonth == 12)  

        return new DateTime(DateTime.Now.Year, 1, 1);   

else   

        return new DateTime(DateTime.Now.Year, parMonth + 1, 1); 

}  

 



I don't know but this error occurs only when Report first time open after user logged in application. After user second time open this report then this error don't occurs,
please review above code and give me reply what is the problem in above code.
I am waiting your reply. Please give me reply as soon as possible.

Thanks in advance.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 20 Jan 2010, 09:23 AM
Hello Projects Computerra,

The following KB article lists all known reasons for this error to occur: The expression contains undefined function call MyUserFunction() error. Please review it carefully and let us know how it goes.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Projects Computerra
Top achievements
Rank 1
answered on 22 Jan 2010, 07:06 AM

Hello steve,

Thanks for your reply.

I have checked the link that you mentioned and also check 3 cases that might be cause of error.

My code ( Code that i sent you ) is correct and doesn't match any of the three cases for causing error.

Can you please check the code and tell me what is problem....

I think there is some problem in Telerik design generation.

Thanks in advance

0
Steve
Telerik team
answered on 26 Jan 2010, 01:26 PM
Hi,

I have not been able to reproduce the problem in a sample report I've created (see attached) with your user functions and some sample data. Since you state it works the first time, I suggest you set breakpoints in the user functions and debug exactly what's happening.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Steve
Telerik team
answered on 27 Jan 2010, 01:10 PM
Hi,

This is just a quick follow up, since the error is reproducible with my sample report if a value is null. So the KB article I've referenced in my first post does cover this scenario - #3. Make sure that such cases are handled in the user function.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Projects Computerra
Top achievements
Rank 1
Answers by
Steve
Telerik team
Projects Computerra
Top achievements
Rank 1
Share this question
or