Page 1 of 1

Handler not working

Posted: Thu Mar 22, 2018 4:34 am
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.

Re: Handler not working

Posted: Sat Mar 24, 2018 3:24 pm
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.

Re: Handler not working

Posted: Mon Mar 26, 2018 12:45 pm
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.

Re: Handler not working

Posted: Wed Mar 28, 2018 6:40 am
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.