Coder Social home page Coder Social logo

Comments (7)

rb-cohen avatar rb-cohen commented on July 30, 2024

If you call loadReport() you should get back lots of information on the report, including the parameters. Each parameter should have a required flag on it.

Something like this:

<?php
require(__DIR__ . '/../vendor/autoload.php');

$options = array(
    'username' => 'testing',
    'password' => 'password'
);

$ssrs = new \SSRS\Report('http://localhost/reportserver/', $options);
$result = $ssrs->loadReport('/Reports/Reference_Report');

$parameters = $result->getReportParameters();

from php-ssrs.

oranges13 avatar oranges13 commented on July 30, 2024

How do you retrieve conditional parameters? For example: based on the parameter chosen in one field, it updates the available params in another field. I'd prefer to default this value if I can before loading the list of parameters the first time.

Is this possible?

from php-ssrs.

rb-cohen avatar rb-cohen commented on July 30, 2024

IIRC you have to update the parameters, then grab the 'updated' conditional parameters from SSRS. I don't think you can get a list of everything right off the bat.

It has been a while, but we did something like this, where $knownValues are the default values or the previously submitted values:

$executionParameters = new SSRS_Object_ExecutionParameters($knownValues);
$newExecutionInfo = $ssrs->setExecutionParameters($executionParameters);

$ssrs->setSessionId($newExecutionInfo->ExecutionID);
$newParameters = $newExecutionInfo->getReportParameters();

// here we had a form generator, eventually populating a HTML form based off the available parameters and values
$formGenerator->generate($newParameters);

$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV

from php-ssrs.

oranges13 avatar oranges13 commented on July 30, 2024

Thanks for the response. Unfortunately this code doesn't work. Here's the full snippet of what I tried:

This code fails with "Session ID not set"

// You need to connect to the server and load your report
$ssrs = new \SSRS\Report('http://myserver/ReportServer', array('username' => 'user', 'password' => 'password'));
$report = $ssrs->loadReport('/Folder/Report');

// Add execution parameters from submission
$execution_params = new \SSRS\Object\ExecutionParameters($requestedFilters);
$new_report = $ssrs->setExecutionParameters($execution_params);

$ssrs->setSessionId($new_report->ExecutionID);

// Params to send to the form view
$available_params = $new_report->getReportParameters();

Your other examples in the wiki indicate that the session id has to be set in the same statement as the setExecutionParameters but if I use that session ID, the parameters I get at the end are just the defaults, not reflective of the data I sent for the report.

// If I instead use the previous session ID:
$new_report = $ssrs->setSessionId($report->ExecutionID)->setExecutionParameters($execution_params);

// Do not reflect the values submitted
$available_params = $new_report->getReportParameters();

// Just for giggles and grins
$new_report->executionInfo->Parameters; // this is null

Here's an example -- you can see value is null even though I am sending a value and the report executes as if a value has been sent.

array:9 [▼
  0 => ReportParameter {#1181 ▼
    +name: "parForecastDate"
    +value: null
    +data: array:13 [▶]
  }
  1 => ReportParameter {#1555 ▼
    +name: "parMonths"
    +value: null
    +data: array:13 [▶]
  }
  2 => ReportParameter {#1561 ▼
    +name: "parType"
    +value: null
    +data: array:13 [▶]
  }
]

The issue with this is that sending these available parameters to our form builder, and one of them has no options available because it's not showing a value for a dependency.

At this point I'm stumped and I might have to build the form filters manually and just send the data to get the report.

from php-ssrs.

rb-cohen avatar rb-cohen commented on July 30, 2024

If the execution ID isn't updated any subsequent requests won't reflect your submission. The execution ID from SSRS is like a state marker.

In your example, where you keep the old session ID, you'll get back the state before you submitted anything.

Unfortunately I don't have access to an SSRS server at the moment to run some tests, but the code should work. Here is a fuller example from the snippet I sent, you'll see we keep updating the session ID to the latest execution ID:

$ssrs = new SSRS_Report('http://testing/reportserver/', $options);
$executionInfo = $ssrs->loadReport($reportName);
$ssrs->setSessionId($executionInfo->ExecutionID);

$executionParameters = new SSRS_Object_ExecutionParameters($knownValues);
$newExecutionInfo = $ssrs->setExecutionParameters($executionParameters);

$ssrs->setSessionId($newExecutionInfo->ExecutionID);
$newParameters = $newExecutionInfo->getReportParameters();

// here we had a form generator, eventually populating a HTML form based off the available parameters and values
$formGenerator->generate($newParameters);

$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV

Hopefully that helps a bit? Sounds like its almost there...

from php-ssrs.

oranges13 avatar oranges13 commented on July 30, 2024

from php-ssrs.

rb-cohen avatar rb-cohen commented on July 30, 2024

Phew, good to hear! :)

from php-ssrs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.