Home
Intelligence (Analytics)
Parameter passing not working
stillarookie
<p>Hi,</p>
<p> </p>
<p>(Neon.1a Release (4.6.1)</p>
<p> </p>
<p>I have a filter which is connected to a parameter. the parameter is a funding source, where a common value is something like: FHOP [POP 20160-2017] - that is an example of a value that should be passed to the query.</p>
<p> </p>
<p>The filter is:</p>
<p> </p>
<div>if(params["RP_FundingSource"].value.value!=null)</div>
<div>row["FUNDING"]</div>
<div>else</div>
<div>null</div>
<div> </div>
<div>like</div>
<div> </div>
<div>'%'+params["RP_FundingSource"].value+'%'</div>
<div> </div>
<div>But nothing is passed to the filter as Preview Results shows records (which it shouldn't if there is a paramter involved.</div>
<div> </div>
<div>When i run the report, despite getting 18 records returned when running the exact same query in dbvis, in BIRT I get nothing.</div>
<div> </div>
<div>What am I doing incorrectly?</div>
Find more posts tagged with
Like
Comments
Clement Wong
<p>Where is the filter defined? On the table, or at the Data Set level? Either of these will not push the filter down to the database.</p>
<p> </p>
<p>You will need to update the query dynamically. You can do this via the <em>Data Set > Edit Data Set > Property Binding > Query Text</em>, or via script in the Data Set > <em>beforeOpen </em>event.</p>
<p> </p>
<p>Here's a simple example and let's say you have the base query as "SELECT * FROM CUSTOMERS", and you want to filter by a country parameter.</p>
<p> </p>
<p>In the Property Binding > Query Text, you can write the JavaScript expression:</p>
<pre class="_prettyXprint">
if ( (params["pCountry"].value !== null) || (params["pCountry"].value != '') )
"SELECT * FROM CUSTOMERS WHERE COUNTRY = '" + params["pCountry"].value + "'";
else
"SELECT * FROM CUSTOMERS";</pre>
<p>Or you can choose to use script in the <em>beforeOpen </em>event:</p>
<p> </p>
<p>Set the query to be:</p>
<pre class="_prettyXprint">
SELECT * FROM CUSTOMERS WHERE 1=1</pre>
<p>And in the <em>beforeOpen </em>event:</p>
<pre class="_prettyXprint">
if ( (params["pCountry"].value !== null) || (params["pCountry"].value != '') )
this.queryText = this.queryText.replace("1=1", "COUNTRY = '" + params["pCountry"].value + "'");</pre>
<p>I noticed in your code above you have two ".value" as in <strong>params["RP_FundingSource"].value.value</strong>, where you should only have one ".value".</p>
stillarookie
<p>Thanks for catching the typo (two .values in the filter) - but that didn't fix anything.</p>
<p> </p>
<p>I have a report parameter, and the filter is on the Query (when you edit the query you have Computed Columns, Parameters, Filters...) do what do you refer to that? </p>
<p>Why won't that filter automatically receive the value of a parameter when passed to it using the above filter setup?</p>