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

Error 'The expression contains undefined function call AllValues().' while exporting reports programatically.

5 Answers 184 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Soumya
Top achievements
Rank 1
Soumya asked on 02 Apr 2014, 08:55 AM
Hi,

I have created a C# windows forms application to export reports programatically. Reports are created using standalone report designer and added in a folder within the application. Reports have a multivalue parameter site whose value is set to AllValues(Fields.Id). AllValues function by default selects all site values. While running the application, report is exported programmatically. But, when I check the report that is created, it has the following message
An error has occurred while processing Report 'GameMetric':
The expression contains undefined function call AllValues().
Following is the piece of code which exports report programmatically.
try
                    {
                        Telerik.Reporting.UriReportSource URI = new Telerik.Reporting.UriReportSource();
                        string reportKey = dt.Rows[i]["report_key"].ToString();
                        string reportName = dt.Rows[i]["report_name"].ToString();
                        appendMessage("Run Report: " + reportName, ref message);

                        if (dt.Rows[i]["CustomFlag"].ToString() != "Y")
                            URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + reportKey + ".trdx";
                        else
                            URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + "Dynamic Report.trdx";

                        XmlReaderSettings settings = new XmlReaderSettings();
                        settings.IgnoreWhitespace = true;
                        using (XmlReader xmlReader = XmlReader.Create(URI.Uri, settings))
                        {
                            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                            ReportViewer reportViewer = new ReportViewer();
                            Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
                                                  new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();

                            Telerik.Reporting.Report report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
                            string newConn = Common.changeConnectionString(Properties.Settings.Default.ParafaitConnectionString, "ParafaitMultisite");
                            System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
                            //SetConnectionString(newConn, report);
                            reportViewer.Report = report;
                            reportViewer.ReportSource.Parameters.Add("fromdate", fromDate.ToString());
                            reportViewer.ReportSource.Parameters.Add("todate", toDate.ToString());
                            //reportViewer.ReportSource.Parameters.Add("offSet", Convert.ToString(ParafaitTimezone.FinalOffset()));
                            reportViewer.ReportSource.Parameters.Add("user", "Parafait Scheduler");
                            reportViewer.ReportSource.Parameters.Add("loggedInUserName", "Parafait Scheduler");
                            reportViewer.ReportSource.Parameters.Add("role", " ");
                            reportViewer.ReportSource.Parameters.Add("loggedInUserId", Common.getLoggedinUser());
                            string reportID = dt.Rows[i]["report_id"].ToString();
                            reportViewer.ReportSource.Parameters.Add("reportID", reportID);
                            reportViewer.ReportSource.Parameters.Add("isCorporate", "Y");
                            //reportViewer.RefreshReport();
                            string fileName = "D:\\Parafait Home\\Reports\\" + reportName + TimeStamp + ".pdf";
                            try
                            {
                                Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", reportViewer.ReportSource, deviceInfo);
                                using (FileStream fs = new FileStream(fileName, FileMode.Create))
                                {
                                    fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
                                }
                            }
                            catch (Exception ex)
                            {
                                appendMessage(ex.Message, ref message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        appendMessage(ex.Message, ref message);
                    }
                }
                
                appendMessage("Done creating reports", ref message);

I have added the assembly reference in report designer config file.

When I run the same set of reports in a web form it seems to be working without any issues.
What wrong could I have done?

5 Answers, 1 is accepted

Sort by
0
Hinata
Top achievements
Rank 1
answered on 07 Apr 2014, 08:21 AM
Hi Soumya,

Check if the issue is not one of the listed issues here: http://www.telerik.com/support/kb/reporting/styling-and-formatting-reports/details/the-expression-contains-undefined-function-call-myuserfunction()-error

If the above doesn't solve the issue you may need to add an assembly reference in the application configuration file to where the user function resides:
<configSections>
    <section
             name="Telerik.Reporting"
             type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting"
             allowLocation="true"
             allowDefinition="Everywhere"/>
</configSections>
    
...
    
<Telerik.Reporting>
    <AssemblyReferences>
      <add name="MyAssembly" version="1.0.0.0" culture="neutral" publicKeyToken="null" />
    </AssemblyReferences>
</Telerik.Reporting>


0
Soumya
Top achievements
Rank 1
answered on 08 Apr 2014, 06:36 PM
Hi Hardik,

Thank you for the reply. I had already gone through the link that you sent. Did you mean to say I must add assembly reference in config file of report designer? I have already added assembly reference in report designer's config file. It works without any issue for web application. Windows application gives error. Is there anything else that I could try?
0
Hinata
Top achievements
Rank 1
answered on 11 Apr 2014, 02:14 PM
Hi Soumya,

Since it is a WinForms application, the reference in the config file of the report designer is irrelevant. You will need to add it to the app.config file of your WinForms application. I think this will fix it.
0
Soumya
Top achievements
Rank 1
answered on 11 Apr 2014, 02:35 PM
Hi Hardik,

I have tried that as well and it din't help. 
0
Hinata
Top achievements
Rank 1
answered on 16 Apr 2014, 11:22 AM
Hi Soumya,

Honestly, I am at a loss how to proceed. All of the above suggestions have helped me in the past and I can't think of anything else that may be an issue in this case. It might be best if you send your project or an isolated sample showing the issue.
Tags
General Discussions
Asked by
Soumya
Top achievements
Rank 1
Answers by
Hinata
Top achievements
Rank 1
Soumya
Top achievements
Rank 1
Share this question
or