Hi All,
I have created report 1 and report 2. Both have different SQL queries. Report 1 has a column called CustomerName that I made as Hyperlink.
On click of Hyperlink CustomerName, I want a report 2 to open, after successful execution on SQL in report 2.
I have everything working except --- not able to pass the CustomerName value to report 2 SQL query.
report 2 SQL query has where part as ...... WHERE customer_name = $P{CustomerName}
This $P{CustomerName} is just not getting the value say IBM when customer clicks IBM hyperlink in report 1
like the report 2 query should become like WHERE customer_name = 'IBM' kind of thing.
What is the way in IREport 3.0 to pass parameter value from Report1 TO SQL query param of report 2 ??
What wizard steps can do this ?
thanks again,
keshub
14 Answers:
Not sure how you generate the report2, but I suppose you have some kind of server that takes care to generate the second report. Then I suppose this url will take a parameter (CustomerName?) so you have to pass this parameter in the url (or let jasperreports to add it for you declaring an Hyperlink parameter.
Then the responsability of passing the parameter to the report2 is up to the code you use to generate it.
JR alone has not drill down capabilities, you need a backend app like JasperServer, or your one.
Giulio
Not sure how you generate the report2, but I suppose you have some kind of server that takes care to generate the second report.
" "BOTH reports generated using "Report Wizard" of IReport 3.0 Both reports are in seperate "Report Units" Both report has their own SQL statements I put during wizard. Both report inits compile success within Ireport and also get uploaded to JasperServer. ""
Then I suppose this url will take a parameter (CustomerName?) so you have to pass this parameter in the url (or let jasperreports to add it for you declaring an Hyperlink parameter.
""Yes used Hyperlink parameter and created 2 additional parameters using IReport wizard so CustomerName and report2 unit does appear in URL. Actually it also open report2 on click of hyperlink. except the report2 says "the report is empty"
Then the responsability of passing the parameter to the report2 is up to the code you use to generate it.
"As I said, Since I used IReport wizards to generate both report units --- I DO not have my own java code. Thought my own code is NOt needed since I am using WYSIWUG IReport designer and Jasper Report"
JR alone has not drill down capabilities, you need a backend app like JasperServer, or your one.
"Drill down/Hyperlink I implement using help from book --- definative guide to Ireports I DO have JasperServer where both report units are sitting at this point" tomcat is my web server. "" My report2 SQL where clause $P{CustomerName} is not getting the real value say ..... "IBM LIMITED" and hence report2 keeps showing empty. Thats the issue.
Hi Giulio,
Thanks for your response. I am using IReport 3.0, JasperServer and Tomcat.
a>Created Report1 and Report2 using IReport's "IReport Wizard". Both these reports are in seperate REPORT UNITS. In wizard I put the respective SQLs. My Report2 SQL does have the ............ WHERE CustomerName = $P{CustomerName} the value 'IBM' or 'Sun' or 'Oracle' etc I am expecting to provide from Report1's CustomerName --- Hyperlink column click.
I used the "Hyperlink" tab ------ "Self" ------ "Report Execution" and in Link Parameter tab added two parameters
_report as "/reports/samples/report2" and
CustomerName as $F{CustomerName}
In report2 "Add Value Parameter" defined parameter as
Parameter Name as CustomerName and
Default Value Expression as ""
Hoping this is the parameter I have in Report2's SQL as $P{CustomerName} and it would noe get its value from report1 hyperlink.
b>I compiled both the reports in IReport. Compile successful. !
c>So each of these report units, I right click and "Run Report Unit". Both reports now go sit in the Jasper Server repository.
d>I go JasperServer UI and then open my Report1 from repository. It opens successfully. Then in column1 I notice Hyperlinks show up like IBM Oracle HP etc so i click say IBM hyperlink. This click opens the Report2 with the URL in the browser of JasperServer showing up as follows........................................
http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&repo...
Please notice in above URL, report2 and CustomerName is correctly constructed.
It also opens the report2 in the JasperServer browser, but unfortunately its shows "The report is empty."
UPtill now I am happy, the FULL circle from report1 hyperlink click to opening the report2 in jasperserver is succeesful ---- EXCEPT report2 is empty. I know why it says empty.
REASON is ------ report2's SQL WHERE clause is just not getting that "IBM LIMITED" value (either from the URL OR whichever other option/wizard etc might be. I just dont know, what is the way you can transport the parameter value between 2 report units and be able to supply to SQL param$P{CustomerName} ????
Now can u please help me how to solve this last part of puzzle using IReport JasperServer combination ? Most important point is both these reports are in two seperate Report Units.
If this is resolved then I am going GOOD !!!
thanks,
keshub
THE url got trimmed in above port so sending again .............
http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&
reportUnit=%2Freports%2Fsamples%2Foracletomysqllimit6
&CustomerName=FUJITSU+LIMITED&_eventId_drillReport=
&_flowExecutionKey=_c6F8AD19C-001F-3214-D548-CD9EF0BA6E21_k039A41B2-C696-C776-F942-F1AFD14EC883
&reportLocale=en_US
Thanks to All. I got this working. Now what I have is Hyperlink in report1 that generates a correct URL with parameters and then calls the report2 (located in seperate Report UNit) and parameter from report1 is passed to SQL $P of report2 VIA URL. I have a real dynamic hyperlink working !!!! that was so cool !!!
Hi keshub, can u explain exactly what u do...i have follow the discussion betwenn u and Giulio but i'm just little bit newbie on ireport and jasperserver.
My scenario it's very similar to your... can u post the 2 report in way that i understand the right way.
I have followed what u describe but sincerally i cannot go on due to error....
thx
Hi Fgar,
my case was, I had a hyperlink(drilldown) on report1 and say user clicks on hyperlink "xyz inc" then i have report2 that will show
the correct records for xyz inc. bcaz in report2 i have a where clause like ......... WHERE companyname=$P{CustomerName}
so the challenge i was facing was how to pass that "xyz inc" to report2 SQL where clause.
so the key is, in report1 u have to have a correct URL that will get invoked after hyperlink click. rightclick the hyperlink ---- Hyperlink tab ---- Self ----- Report Execution --- Reference
"http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&repo...
oracletomysqllimit6&standAlone=true&ParentFolderUri=/reports/samples"
oracletomysqllimit6 is the reportunit name of report2
Sililarly under Hyperlinktab --- Link Parameters tab ---- give yours as -- CustomerName and $F{CustomerName}
similarly TextField tab ----- java.lang.String (since mine parameter is string) ---- Now --- $F{CustomerName}
Now select report2 "Input Control" in ireport repository and right click ----- "Create a new input control" give CustomerName every where under General tab and then under "Input Control details" tab select "Single Value" and check Mandatory checkbox.
Now report two you already must have query ....... WHERE companyname=$P{CustomerName}.
compile both reports. and then rigth click "Run both Report Units". Now both are sitting on JasperServer repository.
Run repot1 in server, click hyperlink, that will pass the clicked value to WHRE clause of report2 and that SQL gets executed and you have report2 displayed with correct records.
boom you have drill down working. !!!!!!!!!!!!
remember CustomerName is ur hyperlink column in report1 that appears on report1 (in design mode). and its case senssitive where ever u pass it. so take special care as u reference it throughout.
remember I am using IReport 3.0 version. check urs.
hope that helps.
Enjoy !!
keshub
keshub,
i was trying to follow your instruction on creating a drill-down report, but failed. Eevn though I put
something like
in the
hyperlink ---- Hyperlink tab ---- Self ----- Report Execution --- Reference,
at runtime, it doesn't invoke it, instead it invoke a URL which was randomly generated - something like
Do you know why?
First, get the url of the 2nd report you want to target, like this:
then in the hyperlink tab set the hyperlink type into reference then add the name of the parameter at the end of the url like this:
"http://localhost:9090/jasperserver-pro/flow.html?_flowId=viewReportFlow&...
EmployeeID is the parameter in 2nd report...
then concat the field where you would get the value for the parameter like this:
"http://localhost:9090/jasperserver-pro/flow.html?_flowId=viewReportFlow&... + $F{UserID}
then paste this in the hyperlink reference expression...
my ireport version is 3.7 ... i'm not sure if this will work on your versions but, it works fine on my version...