Handler not working

Stimulsoft Reports.PHP discussion
Post Reply
mwalters
Posts: 3
Joined: Tue Mar 20, 2018 3:48 am

Handler not working

Post by mwalters »

Good afternoon, I am having trouble getting a report to run using a parameter in the Handler.php file.

I have set a variable in the report and applied it against the SQL statement using curley brackets

Code: Select all

WHERE `ID` = "{Filters}" 
but am having no luck getting it to run correctly.

example.

Code: Select all

<?php
require_once "stimulsoft/helper.php";

// Please configure the security level as you required.
// By default is to allow any requests from any domains.
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Engaged-Auth-Token");

$handler = new StiHandler();
$handler->registerErrorHandlers();

$handler->onBeginProcessData = function ($args) {
	$args->parameters["Filters"] = "SO-100001";

	return StiResult::success();
};

$handler->process();
You can see in the above I use the $args->parameter then the variable name and value, but this is simply ignored.

If I hardcode the value into the report builder it works fine, but I really need to call this dynamically from PHP.

I have tried using both versions 2018.1.6 and 2018.1.8 but end up with the same result

Am I doing something wrong? Any help would be appreciated.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Handler not working

Post by Alex K. »

Hello,

For Reports.PHP-JS there is a nuance - if the same variable in the SQL query is present in the report dictionary, then its value is used primarily, and that to replace this variable on the server, it must be removed from the report data dictionary.

Thank you.
mwalters
Posts: 3
Joined: Tue Mar 20, 2018 3:48 am

Re: Handler not working

Post by mwalters »

Thank you for this,

I can confirm that this worked. I had to do the following to get it working.

Create the variable in the dictionary to allow me to test the file.
Publish the report and add to my website.
Delete the variable from the dictionary in the builder saved the file and copied the saved file to my published location replacing the file in the Reports folder.

Without the variable in the dictionary I could not publish or preview the report.
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Handler not working

Post by Lech Kulikowski »

Hello,

Unfortunately, at the current moment, it is a behavior of JS engine to work with variables in the query.

We have added this task to our to-do list, we will try to fix or add an additional option in the near future.

Thank you.
Post Reply