Initialize parameter value in store procedure by Report.js

Stimulsoft Reports.JS discussion
Post Reply
sumitparui
Posts: 3
Joined: Fri Jun 12, 2020 1:03 pm

Initialize parameter value in store procedure by Report.js

Post by sumitparui »

Hi,
How do we add a parameter for a store procedure in JS report, I have tried using the variable
in which I have added the variable and initialized the variable to parameter in MRT report
and used below code

report.dictionary.variables.getByName("MAWBnumber").valueObject = "14141411";

but I am getting following error in console
"Procedure or function 'StimulusTest' expects parameter '@MAWBNumber', which was not supplied."

There is no sample/example available for JS report with parameter.

I have tried referring Programming manual
and referred github source code as well but I didn't got any solution


Thank You,
Sumit
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Initialize parameter value in store procedure by Report.js

Post by HighAley »

Hello, Sumit.

You should write your parameter in {}.
The usual parameters are not supported in Reports.JS.
https://www.stimulsoft.com/en/blog/arti ... ql-queries

Thank you.
sumitparui
Posts: 3
Joined: Fri Jun 12, 2020 1:03 pm

Re: Initialize parameter value in store procedure by Report.js

Post by sumitparui »

Hi,

I have tried using different approach to fetch data using SQL query rather than calling Procedure

I have used below query
var FromDate = "2019-01-04";
var ToDate = "2020-30-03";
var CompanyId="32364"
var yearId = "35";
var Client = "0"
var Mode = "Both";

report.dictionary.dataSources.list[0].sqlCommand = "exec usp_GetDutyReport @FromDate=\'" + FromDate + "\', @ToDate= \'" + ToDate
+ "\',@YearId = \'" + yearId + "\',@CompanyID=\'" + CompanyId + "\' ,@client =\'" + Client + "\',@mode = \'" + Mode + "\'";

the above query is working fine in Stimulsoft report tool but when I tried the same by clicking preview in Browser
I am getting "Parse Error" message in pop up and in console.

I can't figure out what I am doing wrong here.
Lech Kulikowski
Posts: 6256
Joined: Tue Mar 20, 2018 5:34 am

Re: Initialize parameter value in store procedure by Report.js

Post by Lech Kulikowski »

Hello,

Parameters are not supported in the JS version. You should use variables in that case:
report.dictionary.dataSources.list[0].sqlCommand = "exec usp_GetDutyReport '{FromDate}',' {ToDate}',{YearId},{CompanyID},{client},{mode};

and set the variable value as
report.dictionary.variables.getByName("FromDate").valueObject = "your value";

Thank you.
Post Reply