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

How to pass a DateTime parameter from javascript

1 Answer 347 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ciaran
Top achievements
Rank 1
Ciaran asked on 20 May 2016, 11:01 PM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Ciaran
Top achievements
Rank 1
answered on 22 May 2016, 01:39 PM
Issue resolved - it was do to with a misspelled parameter name, not DateTime parsing.
Tags
General Discussions
Asked by
Ciaran
Top achievements
Rank 1
Answers by
Ciaran
Top achievements
Rank 1
Share this question
or