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

Profile Attributes within the main query


terco

Recommended Posts

Hello,

I am trying to use the Profile Attributes within the main query of a report.

The idea is to bring that information to the where clause of the query.

There are Parameter available which provide this data:
http://jasperforge.org/plugins/mwiki/index.php/Jasperserver/Cascading_input_controls

LoggedInUserAttributes, LoggedInUserAttributeNames, LoggedInUserAttributeValues and LoggedInUserAttribute_<attribute name>

So far I was able to use LoggedInUserAttribute_<attribute name> in a query, like this:

select *
from table1 t1
where t1.col1 in ($P!{LoggedInUserAttribute_MyAttr1})

For that, I have to save the attributes this way:
[MyAttr1:'Value1a','Value1b']

with the single quotes.

The problem with this solution, besides that's not elegant, is that if a user doesn't have that attribute set, it comes to a Java exception.

If I use LoggedInUserAttributeValues with $X (taking out the single quotes):

select *
from table1 t1
where $X{IN, t1.col1, LoggedInUserAttributeValues}

then all values from all attributes are inserted (not only MyAttr1 values but also MyAttr2) and in a block. From jlog:
where t1.col1 IN (?, ?)
DEBUG JRJdbcQueryExecuter,http-48080-7:305 - Parameter #1 (LoggedInUserAttributeValues[0] of type java.lang.String): Value1a, Value1b
DEBUG JRJdbcQueryExecuter,http-48080-7:305 - Parameter #2 (LoggedInUserAttributeValues[1] of type java.lang.String): Value2a, Value2b, Value2c

Is there a way to use the mentioned Parameters or there are others which allow
the same as LoggedInUserAttribute_<attribute name> does but which are of collection type so that they can be used with an $X .
Or can you think of another way to solve this problem?

Many thanks!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 2 years later...

Hello everyone,

I tried : select *
from table1 t1
where $X{IN, t1.col1, LoggedInUserAttribute_MyAttribute}

But it doesn't work! because LoggedInUserAttribute_MyAttribute return a String element (the value of MyAttribute : city1, city2, city3 or ('city1', 'city2', 'city3'), we can't use IN for String value.

Any one have an idea please?!!

Regards

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