sup03 Posted June 15, 2010 Posted June 15, 2010 Hi,I need to filter data in the report based in logged in user's role. I followed the link http://jasperetl.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=67746This is the jrxml <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User" isForPrompting="false"/> <parameter name="LoggedInUserRole" class="java.util.Collection" isForPrompting="false"> <defaultValueExpression><![CDATA[$P{LoggedInUser}.getRoles()]]></defaultValueExpression> </parameter> <parameter name="LoggedInUserRoleString" class="java.util.Collection" isForPrompting="false"> <defaultValueExpression><![CDATA[$P{LoggedInUserRole}.toString()]]></defaultValueExpression> </parameter> <queryString> <![CDATA[select * from report_roles where $X{IN, role_name, LoggedInUserRoleString}]]> </queryString>This throws an error when deployed on jasperserver3.7. Please let me know if anyone has implemented the same.
ramnik Posted June 30, 2010 Posted June 30, 2010 you can simply use the parameter -> LoggedInUserRoles [ in built parameter] in query select * from report_roles where $X{IN, role_name, LoggedInUserRoles}there is no need to extarct it to string first ..i.e. no need of using LoggedInUserRoleString ..In Built Parameter = LoggedInUserRoles works perfect ..thanks Ramnik KaurSenior QA Engineer
terco Posted August 25, 2011 Posted August 25, 2011 Hello,what ramnik wrote is true.Something important to take into consideration though:"When defining these parameters in a report, don’t use a defaultValueExpression element. Due to a limitation inJasperServer, these parameters are null when a defaultValueExpression is provided."And that could be difficult to see if you are not working directly into the JRXML file: once you have defined a default expression and deleted it (let that field empty in iReport), the entry <defaultValueExpression><![CDATA[]]></defaultValueExpression>within that Parameter (LoggedInUserRoles) stays in the JRXML file forever (causing LoggedInUserRoles to be null !) unless you deleted it manually!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now