Jump to content
We've recently updated our Privacy Statement, available here ×

babs

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

The way I have done for drill down is this:

On the report 1, open up the properties dialog for the element you want to make into link.

Click on the Hypelink tab. On the bottom, you should see a sub tab called "Link parameters"

What you want to do here is add the following parameters:

 

Link Parameter: _report

Expression: <location of the report to bring up> eg. "/Reports/CompanyReport"

 

Link Parameter: <name of the parameter> eg. CompanyName

Expression: <the value that you want to pass for this parameter> eg. IBM

 

If you need to add another parameter, just add another pair of  Link Parameter/Expression.

 

What I find limiting is that hardcoding of the drill down report location (/Reports/CompanyReport). If you know a way to get around this, please share.

 

Nghia

 

Link to comment
Share on other sites

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&

reportUnit=%2Freports%2Fsamples%2Foracletomysqllimit6

&CustomerName=FUJITSU+LIMITED&_eventId_drillReport=

&_flowExecutionKey=_c6F8AD19C-001F-3214-D548-CD9EF0BA6E21_k039A41B2-C696-C776-F942-F1AFD14EC883

&reportLocale=en_US



 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 7 months later...

I am experiencing the same problem described in this posting.  My 1st report has a column that I have defined to be a hyperlink to do ReportExecution as follows:

Hyperlink Reference:  "http://frc-xxxx:8080/jasperserver/flow.html?_flowId=viewReportFlow"

2 Link Parameters: reportUnit         "/reports/ASM/SubReports/Expiring_Accred_Org"

                                   P_ORG_ID      $F{ORG_ORGANIZATION_ID}

Running the 1st report in JasperServer does successfully show the column as a hyperlink and it does successfully call and run the correct 2nd report, but the report is always showing the data for the default P_ORG_ID - it is ignoring the P_ORG_ID value being passed in the URL.  Here is the actual JasperServer URL showing that the value IS indeed being passed.  http://frc-xxxx:8080/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=%2Freports%2FASM%2FSubReports%2FExpiring_Accred_Org&P_ORG_ID=1080886&_eventId_drillReport=&_flowExecutionKey=_cF061C938-E7B8-EA0F-E29C-AD36F0AB529E_k7EA7C683-7AFC-B79E-EC9A-DA6EDEB6CAA7&reportLocale=en_US

Is there something I have to do with the Report Unit of the 2nd report in JasperServer so it will actually use the value passed via the URL?  Just a guess... do I need to set up an Input Control for P_ORG_ID?  That doesn't seem logical since the Input Control will never actually be used (since this 2nd report will only be available by hyperlink from the 1st report).

How did you get it to work?  I appreciate any hints anyone can provide.  Thanks.

James

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

 

This is very cool. But I have a question.

 

In Report 2, do I need to set the parameter's "isForPrompting" to false? I am asking this because I saw the URL seemed to have been correctly constructed, but I still see the prompt page when Report 2 is being executed. I want to suppress this prompt page.

 

Thanks!

Link to comment
Share on other sites

Hi,

 

I noticed that the prompt page is controlled by the "Alway prompt" check box in Report Wizard (in JasperServer, select the report, and then click "Edit", and then go to the step of "Controls & Resources". 

 

So now I can pass parameters between reports.  That is very cool. Thank you so much!  But I have another question now ... it seems that the above mechanism does not pass parameters of type "java.util.Collection" (multi-select input control).    Is that true?

Link to comment
Share on other sites

Hello,

My understanding is , since the parameters are transmitted inside a URL, they need to be strings. At the beginning, when I tested jasperserver with hyperlinks, I succeeded in transmitting java.util.collections as strings in the URL (in fact, you must "cast" the collection to obtain a string like "[1,2,3,...,N]" then replace the "[ ]" by parenthesis to get "(1,2,3,..,N)" and finally use this parameter in the query not with $X{..} but with " and Field1 in $P!{Param}".

As far as I remember, there is a tip for casting the java.util.collection into a string : you must concat a null string :

" " + $P{JavaUtilCollection}

Hope this will help you

If I find my first test I will post it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...