Search code examples
jasper-reportsjasperserver

Passing a value from one JasperReports Server input control to a another input control


I need somehow to achieve levels of hierarchy in a input control. For example a user needs to select a certain organization, and every organization has some sub organizations and if he selects organization in a drop down I need to show all sub organizations of the selected organization, and I have to leave a possibility when an organization is selected to select all sub organizations, or just one.Likewise, a possibility to select all parent organizations must be there.How to acheive this, I have explored almost all of my options and I'm thinking hat my best bet is to make my own JSP page with parameters, is there any other way to achieve this with already incorporated input controls in JasperReports server?

I'm curently using Jaspersoft Studio 5.6 and JasperReports Server

P.S. a list of parent organiations and their IDs is filled from a query, it's not hardcoded.


Solution

  • It is actually quite easy to accomplish.

    Let's assume that you already have multi-select query input called Organization, witch gives user ability to select Organization name returns company 'ID' numbers. Lets pretend that it SQL looks like this:

     select 
     ORGANIZATION_NAME
     ,ID 
     from organization
    

    Now hat you have to do in Sub_organizations multi-select query SQL is to add where condition pointing to Organization input control. You can do it like this:

     select 
     SUB_ORGANIZATION_NAME
     ,SUB_ORGANIZATION_ID
     ,ORGANIZATION_ID 
     from sub_organization
     where $X{IN,sub_organization.organization_id,Organization}
    

    BTW, in where clause I am referencing name of jasperserver input control parameter, witch returns needed arguments.

    Hope that this will help you ;)