Jump to content
Changes to the Jaspersoft community edition download ×

How to get LoggedInUser parameter from Input Controls


kfreisen

Recommended Posts

Hi,

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>    </parameter>[/code]

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

select briefid, brief_name from alchemy.dbo.brief bwhere 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[/code]

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(JRAbstractQueryExecuter.java:787)
        at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.appendParameterClauseChunk(JRAbstractQueryExecute
r.java:464)
        at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.appendQueryChunk(JRAbstractQueryExecuter.java:373
)
        at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.parseQuery(JRAbstractQueryExecuter.java:358)
        at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.<init>(JRJdbcQueryExecuter.java:139)
        at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.<init>(JRJdbcQueryExecuter.java:147)
        at com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRTimezoneJdbcQueryExecuter.<init>(JRTimezoneJdbc
QueryExecuter.java:127)
        at com.jaspersoft.commons.util.JSControlledJdbcQueryExecuter.<init>(JSControlledJdbcQueryExecuter.java:65)
        at com.jaspersoft.commons.util.JSControlledJdbcQueryExecuterFactory.createQueryExecuter(JSControlledJdbcQueryE
xecuterFactory.java:26)
        at net.sf.jasperreports.engine.query.AbstractQueryExecuterFactory.createQueryExecuter(AbstractQueryExecuterFac
tory.java:49)
        at com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRQueryExecuterAdapter.executeQuery(JRQueryExecut
erAdapter.java:92)
        at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.executeQuery(EngineServ
iceImpl.java:2117)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
 

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?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 years later...

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
Arguments:

 

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