How to get LoggedInUser parameter from Input Controls


So we are trying to set up input controls for our reports that would allow up to get the LoggedInUser's user attributes. To give a little bit of context, we are using external authentication, and the user attributes we are using corrsepond to a collection of ids that we can add to join/where clauses in the input control queries. We also custom utility class that allows us to parse the user attributes and transform them into an sql-safe list (for in statements and whatnot, because the raw attribute value is just a comma seperated string of ids).


What I would expect I'd need for this to work is something like this in the jrxml:

    <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User" isForPrompting="false"/>
    <parameter name="userLinkedBriefIds" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[com.jaspersoft.smartbrief.util.UserParamUtil.getAttributeSQLValue($P{LoggedInUser}.getAttributes(), "briefId")]]></defaultValueExpression>

Then that I would be able to access that userLinkedBriefIds from the input control query like:

select briefid, brief_name from alchemy.dbo.brief b
where b.activestatus like 'A%'
and (b.briefname_alias = '' OR b.briefname_alias is null)
and (b.parentid is null)
and b.briefid in $P!{userLinkedBriefIds}
order by b.brief_name asc

But, the input control doesnt even load in the report and we get an error in the logs with a stacktrace like this (abbreviated since its pretty long)

2013-10-01 14:31:17,466 ERROR GenericExceptionMapper,http-8080-5:42 - Unexpected error occurs
net.sf.jasperreports.engine.JRRuntimeException: Parameter "userLinkedBriefIds" does not exist.
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.checkParameter(
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.appendParameterClauseChunk(JRAbstractQueryExecute
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.appendQueryChunk(
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.parseQuery(
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.<init>(
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.<init>(
at com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRTimezoneJdbcQueryExecuter.<init>(JRTimezoneJdbc
at com.jaspersoft.commons.util.JSControlledJdbcQueryExecuter.<init>(
at com.jaspersoft.commons.util.JSControlledJdbcQueryExecuterFactory.createQueryExecuter(JSControlledJdbcQueryE
at net.sf.jasperreports.engine.query.AbstractQueryExecuterFactory.createQueryExecuter(AbstractQueryExecuterFac
at com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRQueryExecuterAdapter.executeQuery(JRQueryExecut
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.executeQuery(EngineServ
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(

I'm able to get the value of the report parameter from the actual report (by either putting it into a text field or by actually using it in the report query), but from the input control its just not working.

Has anyone tried anything similiar and had success?

kfreisen's picture
Joined: Jul 15 2013 - 7:34am
Last seen: 9 years 4 months ago

2 Answers:

Hello Dear,

Logged in user name can be passed to query based input control by using the built-in parameter $P{LoggedInUsername}.

Just put it  $P{LoggedInUsername} ...instead of


This should work . Good luck.

sourabh.g's picture
Joined: Jul 20 2013 - 12:01am
Last seen: 9 years 10 months ago

but how to manage possibility user has not the attribute? on my installation 6.4.2 occure error:

2018-05-29 08:59:51,583 ERROR ErrorPageHandlerAction,http-nio-8080-exec-5:118 - Error UID ee1e6984-fd7f-44c9-866c-a566c3846a17
com.jaspersoft.jasperserver.api.SessionAttribMissingException: cluster.exception.session.attribute.missing


cosmohide_1's picture
Joined: May 31 2018 - 8:54am
Last seen: 5 years 3 months ago