Convert Comma Separated Profile Attribute to list in Jasper Reports

 

As we know, we can add profile attribute to jasper server but which accepts only string type parameter. So this blog will help you to convert string profile attribute to list.

We know that the built in parameter LoggedInUserAttribute_<Attribute Name> is used to access value of that particular profile attribute by replacing <Attribute Name> to corresponding profile attribute name. But this will return the data in string format. So to convert this string data into list do the following.

  • Create subreport or new dataset
  • Create a parameter (say StateList) into new dataset or subreport with data type as List
  • Now at the time assigning value to parameter(StateList) do this

statelist=Arrays.asList($P{LoggedInUserAttribute_<Attribute Name>}.split(","))

  • Now you can use this parameter as a list in your SQL query either in subreport or new dataset.

Note: Your profile attribute should be in comma separated format.

Leave a Reply