Get Free Trial

How to pass custom parameters to SQL server query

Answered
nisha asked on July 7, 2021

Hi Team,
We are using the Flexmonster admin Panel and using SQL queries and Stored procedures for the indexes. Our query is parameterized so we wanted to pass parameters to it. 
Also, We don’t want to use .NET custom API approach where we pass API url and can add parameters in request headers.

Could you suggest the way how to pass parameters to the flex report?
Can we pass the parameters from datasource property where we pass the index names?
 
Thanks!

1 answer

Public
Vera Didenko Vera Didenko Flexmonster July 8, 2021

Hello,
 
Thank you for writing to us.
 
Flexmonster Data Server is a ready-to-use implementation of the custom data source API. By design, Flexmonster Data Server keeps data indexes in the RAM, so it relies on predefined indexes. Therefore, Flexmonster Data Server doesn’t support parameterized queries. 
 
The best solution for using parameterized queries is to create your own server implementing the custom data source API protocol. Such an approach will give you full control over how the data is processed, including the possibility to handle parameterized queries and much more.

Aside from passing an API URL, you can also use the callback function approach. This can be achieved by specifying a function instead of an URL in the "url" dataSource object’s property.
The function accepts three parameters: the request, on success callback function, and on error callback function, for example:

var pivot = new Flexmonster({
...
report: {
dataSource: {
type: "api",
url: pivotEndpoint,
index: "index"
},
...
}
...
}


function pivotEndpoint(request, successCallback, errorCallback) {

console.log("request >>>", request);

// add further logic here (for example, get the response from your server)

successCallback(response);

}

This way, Flexmonster will provide the current request that needs to be processed and listen to the callback function on how to proceed further. The response that is passed in the successCallback function needs to be in a specific format (see the following link for more details).
 
 
Please let us know if further questions arise.
 
Kind regards,
Vera

Please login or Register to Submit Answer