SubReport cannot identify parameter

6 posts, 0 answers
  1. Michael Gois
    Michael Gois avatar
    17 posts
    Member since:
    Oct 2008

    Posted 16 Nov 2010 Link to this post

    Hi
    I am getting the following error when I produce a report which contains a sub report, and the sub report relies on filtering using a parameter: - The expression contains object 'parExpenseFormId' that is not defined in the current context. It doesnt seem to recognise that I have already added the parameter although I have.
    This worked absolutely fine in an older version of Telerik Reporting but I have now had to upgrade to version 4.1.10.71 (Q2 2010) I am getting the error. I cannot use Q3 because it has another bug which prevents me from using it.
    Can someone please help me - I am generating my SubReport in the following manner:

    1. Main Report

    SubReport

     

    oSubRep = new SubReport();

     

     

    Report oEntriesRep = ExpenseEntriesReportBuilder.GetReport(); // Create the sub report (see extract below)

     

    oSubRep.Width =

    new Unit(735, UnitType.Pixel);

     

    oEntriesRep.DataSource = dsData.Tables[1];

    oSubRep.ReportSource = oEntriesRep;

    oSubRep.Parameters.Add(

    "parExpenseFormId","Fields.[expense_form_id]");
    oDetails.Items.Add(oSubRep); // Add the subreport to the details section of the report

    2. This is how I generate the actual sub Report

     

     

     

    ExpenseEntriesReportBuilder. GetReport()

     

    {

     

    Report oRep = new Report();

     

    oRep.PageSettings = GetPageSettings();

    oRep.Items.Add(GetHeaderSection());

    oRep.Items.Add(GetDetailSection());

    oRep.Items.Add(GetFooterSection());

    oRep.Filters.Add(

    new Filter("=Fields.[expense_form_id]", FilterOperator.Equal, "=Parameters.parExpenseFormId"));

     

     

    return oRep;

     

    }

    Thanks in advance

  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 17 Nov 2010 Link to this post

    Hi Michael Gois,

    You've omitted to mention the most important thing - where do you use this code? Since we do not see anything dynamic in this setup, is there a reason why you have not set this up through the Report Designer like elaborated in the Creating Master-Detail Reports Using SubReports help article?

    Kind regards,
    Steve
    the Telerik team
    See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
  3. DevCraft banner
  4. Michael Gois
    Michael Gois avatar
    17 posts
    Member since:
    Oct 2008

    Posted 18 Nov 2010 Link to this post

    Hi Steve

    Well I kept the code simple so that you could see the important bits. The report has to be dynamic as there are a number of fields which are either included or not included depending on certain things and names of field captions change depending on configuration as well. I considered using anchors to have fields that may or may not exist but it makes the report difficult to manage.

    Now the strange thing I have noticed is I have another report which constructs the subreport in EXACTLY the same way, but it doesnt produce this error! The other interesting thing is if I set the value of parExpenseFormId I can get it to work, it seems to only break down when it has to get expense_form_id from the master report dataset, even though the field is present (as I mentioned before, this report worked fine with older versions of telerik reporting)

    oSubRep.Parameters.Add("parExpenseFormId","Fields.[expense_form_id]");
    to
    oEntriesRep.ReportParameters.Add("parExpenseFormId", ReportParameterType.Integer, iExpenseFormId.Value.ToString());
    it works, but I obviously cannot keep a constant value here otherwise it doesnt work for reports which contain multiple expense_form_id values.

    Any suggestions would be appreciated!
    Thanks
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 18 Nov 2010 Link to this post

    Hello Michael Gois,

    One thing I notice now is that you're missing equal sign for the Parameter Value so that it could be evaluated i.e.:

    oSubRep.Parameters.Add("parExpenseFormId","Fields.[expense_form_id]");

    should be:

    oSubRep.Parameters.Add("parExpenseFormId","=Fields.[expense_form_id]");

    or even better:

    oSubRep.Parameters.Add(new Telerik.Reporting.Parameter("parExpenseFormId", "=Fields.[expense_form_id]"));

    Best wishes,
    Steve
    the Telerik team
    See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
  6. Michael Gois
    Michael Gois avatar
    17 posts
    Member since:
    Oct 2008

    Posted 23 Nov 2010 Link to this post

    Hi

    Sorry for the late reply, I thought I had found a workaround but just realised I havent! That bit of code was just from me playing around trying different things. It is doesnt work even using

    oSubRep.Parameters.Add(new Telerik.Reporting.Parameter("parExpenseFormId", "=Fields.[expense_form_id]"));

    The issue I have now it doesnt actually even raise an error, but the sub report appears as a red rectangle instead, which is just as bad anyway!

    As I said, this was working fine in Telerik 2009 Q2 but now its stopped. I had found a workaround for the issue I described and went live but now I've discovered this somewhere else and I have to sort it out ASAP as its on my live site. Should I raise a support ticket for faster response time?

    Many thanks !
    Michael
  7. Michael Gois
    Michael Gois avatar
    17 posts
    Member since:
    Oct 2008

    Posted 24 Nov 2010 Link to this post

    Hi Steve,

    Just letting you know I submitted a support ticket for this with an attached solution to reproduce the problem, the ticket id is 369812 . I would like to keep this forum thread open so that when I have an answer I can post it here as well for other users in the future.

    Thanks
Back to Top
DevCraft banner