hyperlink

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

keshub's picture
116
Joined: Oct 22 2008 - 4:00pm
Last seen: 14 years 11 months ago

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

giulio's picture
74183
Joined: Jan 2 2007 - 4:15pm
Last seen: 5 days 17 hours ago

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

 

 

 

 

keshub's picture
116
Joined: Oct 22 2008 - 4:00pm
Last seen: 14 years 11 months ago

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

keshub's picture
116
Joined: Oct 22 2008 - 4:00pm
Last seen: 14 years 11 months ago

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 !!!

keshub's picture
116
Joined: Oct 22 2008 - 4:00pm
Last seen: 14 years 11 months ago

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

fgar's picture
257
Joined: Oct 15 2008 - 4:29am
Last seen: 14 years 11 months ago

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's picture
116
Joined: Oct 22 2008 - 4:00pm
Last seen: 14 years 11 months ago

keshub,

i was trying to follow your instruction on creating a drill-down report, but failed. Eevn though I put 

something like

"http://localhost:8080/jasperserver-pro/flow.html?_flowId=viewReportFlow&reportUnit=/FCI_BI_Dashboard/bi_dsh_inventory_detail&standAlone=true&ParentFolderUri=/FCI_BI_Dashboard"

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

http://localhost:8080/jasperserver-pro/flow.html?_flowId=viewReportFlow&site=FCI&_eventId_drillreport=&_flowExecutionKey=_cA640........................&reportLocale=en_US

Do you know why? 

 

 

 

 

 

 

 

 

 

mbyanfei's picture
Joined: Aug 15 2008 - 8:02am
Last seen: 15 years 1 month ago
by the way, the error message I got is: Error Message: Null URI com.jaspersoft.jasperserver.api.JSException: jsexception.null.uri com.jaspersoft.jasperserver.api.JSException: jsexception.null.uri at com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.HibernateRepositoryServiceImpl.findByURI(HibernateRepositoryServiceImpl.java:572)
mbyanfei's picture
Joined: Aug 15 2008 - 8:02am
Last seen: 15 years 1 month ago
Hi, this did not work for me. IT gives error as NULL URI. Also , date parameter could not be passed to child report. Can you please put complete URL you added as Reference?
npatki's picture
32
Joined: Jan 6 2009 - 5:07am
Last seen: 14 years 8 months ago

Hi

do you have any idea about how we pass a collection to a hyperlink parameter?

Thanks

Nikhil

npatki's picture
32
Joined: Jan 6 2009 - 5:07am
Last seen: 14 years 8 months ago

First, get the url of the 2nd report you want to target, like this:

http://localhost:9090/jasperserver-pro/flow.html?_flowId=viewReportFlow&ParentFolderUri=/reports&ndefined=&standAlone=true&reportUnit=/reports/testLink

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...

rongrajo13's picture
Joined: Mar 24 2010 - 8:21pm
Last seen: 13 years 6 months ago

 

"and then rigth click "Run both Report Units".

 

How can I run both report units and where exactly to right click? I am using Jasper Server 4.5.0

 



Post Edited by xaharhassan at 03/06/2012 05:43



Post Edited by xaharhassan at 03/06/2012 05:45
xaharhassan's picture
Joined: Mar 5 2012 - 9:35pm
Last seen: 11 years 6 months ago

I have exactly the same requirement as Keshub, but am using jaspersoft studio 5.5.0? How to hyperlink there?

 

apoorve.t's picture
Joined: Jan 1 2014 - 5:15am
Last seen: 9 years 4 months ago
I will try to explain this for you just in case it will help someone else that is new. I have two reports one called MLR and one called MLR2. The main report, MLR, shows employee info, like empno, firstname and lastname. MLR2 has the employee's detailed information with address, phone, etc.
 
In MRL, or main report, I used empno for the variable to pass. So in the main report I make a parameter of EmpNum that is equal to $F{EMPNO}
 
Then I right click on empno and select hyperlink.
Hyperlink target is set to self
Hyperlink type is changed to Reference
On the reference tab add the url to the second report, in my case it is MRL2. Go to your jasperserver and open the second report and copy in the url like
 
You can see I added EmpNum, the parameter to the end of the url with &EmpNum=" then added the field to be passed to the second report.
 
So before the quote add &Parametername=
Then after the quote add +$F{whateveryourcolumn name is to be passed}
 
On the Link parameters tab add EmpNum for name and $F{EMPNO} for Expression
 
Save that and upload it to the server
Go to your second report and add and input controls, for me it is EmpNum all the way through for the names.
 
Now when you run the first report it passes the employee number to the second report.
joel.carlson's picture
Joined: Jul 23 2015 - 4:39pm
Last seen: 2 years 5 months ago
Feedback
randomness