How to pass a DateTime parameter from javascript

2 posts, 1 answers
  1. Ciaran
    Ciaran avatar
    6 posts
    Member since:
    Apr 2014

    Posted 20 May Link to this post

    Hi,

    I'm trying to pass a parameter to a Telerik report that is expecting a DateTime parameter from javascript. My code is this:

    $("#reportViewer")
                .telerik_ReportViewer({
                    serviceUrl: "/api/reports/",
                    templateUrl: "/src/vendor/ReportViewer/templates/telerikReportViewerTemplate.html",
                    reportSource: {
                        report: "MyFullyQualified assembly name",
                        parameters: {
                            sessionId: "b57c7405-5d1d-4513-841c-4c7b2015d376",
                            otherId: "8e44c09d-771e-453c-83e9-1723faaed2fd",
                            periodEnd: "2015-06-30"
                        }
                    }
                });

    As you can see the periodEnd is currently represented as a string in javascript. Looking at my Chrome dev tools, it looks like it's failing because the string containing the periodEnd is not being parsed as a .Net DateTime. I've also tried passing a javascript date object i.e. new Date("2015-06-30") with the same result.

    The exception message I'm getting is: "Missing or invalid parameter value. Please input valid data for all parameters."

    The Telerik API response to /api/reports/clients/2334-etc is as follows. You can see that the value for periodEnd is null even though I am specifying it.

    [{"name":"sessionId","type":"System.String","text":"sessionId","multivalue":false,"allowNull":false,"allowBlank":false,"isVisible":false,"autoRefresh":false,"hasChildParameters":false,"childParameters":null,"availableValues":null,"value":"b57c7405-5d1d-4513-841c-4c7b2015d376","id":"sessionId","label":"b57c7405-5d1d-4513-841c-4c7b2015d376"},

    {"name":"otherId","type":"System.String","text":"otherId","multivalue":false,"allowNull":false,"allowBlank":false,"isVisible":false,"autoRefresh":false,"hasChildParameters":false,"childParameters":null,"availableValues":null,"value":"8e44c09d-771e-453c-83e9-1723faaed2fd","id":"otherId","label":"8e44c09d-771e-453c-83e9-1723faaed2fd"},

    {"name":"periodEnd","type":"System.DateTime","text":"periodEnd","multivalue":false,"allowNull":false,"allowBlank":false,"isVisible":false,"autoRefresh":false,"hasChildParameters":false,"childParameters":null,"availableValues":null,"value":null,"id":"periodEnd","label":null}]

    Any help is much appreciated,

    Ciaran O'Neill

  2. Answer
    Ciaran
    Ciaran avatar
    6 posts
    Member since:
    Apr 2014

    Posted 22 May in reply to Ciaran Link to this post

    Issue resolved - it was do to with a misspelled parameter name, not DateTime parsing.
  3. DevCraft banner
Back to Top