robertpopa22 Posted July 1, 2008 Share Posted July 1, 2008 Hi, We have a lot of users and we need to create only one report! We need to use the LoggedInUser.getUsername() or LoggedInUser.getFullName() to filter out records, so that the user can see his (an only his) data in the report. We have tried to use (from the posts existing here) this query: Code: and we have declared the parameter like this: size=300] size=323]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/parameter-e7b4ffca05cf8643b7c2d7a18ad396b4.JPG When we publish the report on the server we receive this error: com.jaspersoft.jasperserver.api.JSExceptionWrapper: net.sf.jasperreports.engine.design.JRValidationException: Report design not valid : 1. Parameter type not supported in query : LoggedInUser class com.jaspersoft.jasperserver.api.metadata.user.domain.User We have studied the SalesByMonths example, but there is a different approach to LoggedInUser. Please help us with an example or tutorial on how to do this in iReports and publish it on the server. Thank You!P.S. If there is another approach to this matter please show us! :woohoo: Link to comment Share on other sites More sharing options...
robertpopa22 Posted July 1, 2008 Author Share Posted July 1, 2008 Here is the parameter declaration: size=323]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/parameter-893f48770c58cfd689473f77cdfb8ff6.JPG http://www.geseidl.ro/images/jasper/parameter.JPG Link to comment Share on other sites More sharing options...
lucianc Posted July 1, 2008 Share Posted July 1, 2008 "WHERE users.name = '$P{LoggedInUser}.getFullName()'" will not work, you'll have to do something like this:Define a new parameter named LoggedInUserName, and set it's default value expression to $P{LoggedInUser}.getFullName().Use $P{LoggedInUserName} in the query (note that you don't need to use quotes around the parameter placeholder).[/ul] HTH,Lucian Link to comment Share on other sites More sharing options...
robertpopa22 Posted July 1, 2008 Author Share Posted July 1, 2008 Thanks, but it doesn't work yet... I have created a 1st parameter $P{LoggedInUser} from class com.jaspersoft.jasperserver.api.metadata.user.domain.User with no default value (also tried prompt and no prompt) Then I created the 2nd parameter $P{LoggedInUserName} of class java.lang.String with the default value of $P{LoggedInUser}.getFullName() (also tried prompt and no prompt) The query was: SELECT details.`Detail` AS details_Detail, users.`name` AS users_name, users.`db` AS users_dbFROM `details` details LEFT OUTER JOIN `users` users ON details.`idUser` = users.`idUser`WHERE users.name = $P{LoggedInUserName} *Note! When I used the default value of "Name1", the report printed out ok, so the query is good. In the SQL Query log we have:SELECT details.`Detail` AS details_Detail, users.`name` AS users_name, users.`db` AS users_dbFROM `details` details LEFT OUTER JOIN `users` users ON details.`idUser` = users.`idUser`WHERE users.name = NULL Please help us to understand what are we doing wrong ... :) Link to comment Share on other sites More sharing options...
lucianc Posted July 1, 2008 Share Posted July 1, 2008 Could you test whether $P{LoggedInUserName}.getFullName() is null or not? A simple way to do this is to display it in a report text field. Link to comment Share on other sites More sharing options...
robertpopa22 Posted July 2, 2008 Author Share Posted July 2, 2008 $P{LoggedInUserName}.getFullName() ? Perhaps you reffered to $P{LoggedInUser}.getFullName() ... Yes, $P{LoggedInUser}.getFullName() returns as String the name of the user... Everything ok here, in the text field. Perhaps there are some differences in the query parser? Link to comment Share on other sites More sharing options...
lucianc Posted July 2, 2008 Share Posted July 2, 2008 Yes, I meant $P{LoggedInUser}.getFullName(). You could also try to show $P{LoggedInUserName} in a text field.. I don't understand why LoggedInUserName's default value expression doesn't work. Could you post your JRXML so that we'd be able to replicate the issue? How are you running the report? Link to comment Share on other sites More sharing options...
robertpopa22 Posted July 8, 2008 Author Share Posted July 8, 2008 Hello, Does anyone know how to make such a query? The suggestions from lucian do not work. Anyone else has any idea? Thanks Link to comment Share on other sites More sharing options...
robertpopa22 Posted July 8, 2008 Author Share Posted July 8, 2008 :laugh: Sorry lucian, I haven't seen your post! I am new here...Here is the jrxml... Please help! :) By the way, is it possible to send a file/image to the forum? until now I only could post links to my website. Link to comment Share on other sites More sharing options...
lucianc Posted July 8, 2008 Share Posted July 8, 2008 You are using $P{LoggedInUser} in the query, and not $P{LoggedInUsername} as you should. Fix this and see whether it works. By the way, is it possible to send a file/image to the forum? until now I only could post links to my website. It should be possible, aren't the image and file attachment controls working? Regards,Lucian Link to comment Share on other sites More sharing options...
Gaby38 Posted July 8, 2008 Share Posted July 8, 2008 Hello, Just to say that I already have a report like the one of Robert which runs a query on the meta database and I filter with the name of the user. I did exactly as Lucian said, that is :- create a 2nd parameter "$P{FullUserName}" initialized by defaut with "$P{LoggedInUser}.getFullName()"- and in my query I have :"where jasperserver.JIUser.fullname=$P{FullUserName}" and it works fine. Link to comment Share on other sites More sharing options...
Gaby38 Posted July 8, 2008 Share Posted July 8, 2008 Hello, Just to say that I already have a report like the one of Robert which runs a query on the meta database and I filter with the name of the user. I did exactly as Lucian said, that is :- create a 2nd parameter "$P{FullUserName}" initialized by defaut with "$P{LoggedInUser}.getFullName()"- and in my query I have :"where jasperserver.JIUser.fullname=$P{FullUserName}" and it works fine. Link to comment Share on other sites More sharing options...
robertpopa22 Posted July 9, 2008 Author Share Posted July 9, 2008 Thank you both! It works now. I have misplaced the parameters. Nice work! Link to comment Share on other sites More sharing options...
huwtrimet.org Posted September 9, 2008 Share Posted September 9, 2008 Does this feature work on the community version? It seems I have misplaced my parameters too, I can not make it work. Link to comment Share on other sites More sharing options...
Gaby38 Posted September 9, 2008 Share Posted September 9, 2008 Yes this feature is in the community version. Link to comment Share on other sites More sharing options...
valbumbu Posted January 2, 2009 Share Posted January 2, 2009 Is there a way to pass a parameter into Input Control's query? In other words I want to generate different multi-select input controls by passing the pasperserver username into the query. Link to comment Share on other sites More sharing options...
valbumbu Posted January 2, 2009 Share Posted January 2, 2009 Is it possible to pass a parameter into the query of a input control (which is multi-select list). So thr list contents will differ depending on the value of the parameter, e.g. $P{LoggedInUserUsername}. I'm able to display the correct value of the username, but looks like the input control's query not receiving it properly, and the content of the list is empty. Link to comment Share on other sites More sharing options...
swood Posted January 14, 2009 Share Posted January 14, 2009 What you are after is what we call "cascading input controls". There is no solution for this right now, but we are looking to package up some extensions to JasperServer you can add to do this. ShermanJaspersoft Link to comment Share on other sites More sharing options...
elam Posted May 6, 2009 Share Posted May 6, 2009 As an appendum to the original post , in case anyone else is trying this, the initial parameter of type class com.jaspersoft.jasperserver.api.metadata.user.domain.User *has* to be named LoggedInUser or a null value will be returned from any method called on it. Strange. Link to comment Share on other sites More sharing options...
federico.cattozzi Posted November 4, 2009 Share Posted November 4, 2009 I have coded like Gaby38 but LoggedInUser seems to not exist.When I attemp to run the report JS3.5 says:com.jaspersoft.jasperserver.api.JSExceptionWrapper: Report design not valid : 1. Parameter not found : LoggedInUserIs there a part in the docs where I can find a list of all JS' built-in parameters? Link to comment Share on other sites More sharing options...
federico.cattozzi Posted November 6, 2009 Share Posted November 6, 2009 Sorry, i hadn't create LoggeInUser parameter but only the second parameter that use it.I named the second parameter USERNAME.I have discover that if you put USERNAME, before LoggeInUser, it's impossible for it to read LoggeInUser parameter.I think that the order of parameters is the order of instantiation. When I read USERNAME, LoggeInUser wasn't instantiated yet.Read the correct code here below: Code: Post Edited by helyair at 11/06/2009 10:05 Link to comment Share on other sites More sharing options...
samerzohdi Posted November 9, 2009 Share Posted November 9, 2009 Hi, - defined new parameter and named username, and set Parameter Class Tyape: java.lang.String, and set Use as aPrompt:Trueand set Default Value Expression: $P{LoggedInUser}.getFullName(), then click OK. - use '$P!{username}' in query. where user.name = '$P!{username}'it should work, I tried it. :) Samer Link to comment Share on other sites More sharing options...
federico.cattozzi Posted November 9, 2009 Share Posted November 9, 2009 Yes, i have just found the solution and i have resolved another problem, read carefully my last post. Link to comment Share on other sites More sharing options...
federico.cattozzi Posted August 30, 2010 Share Posted August 30, 2010 swoodWrote: What you are after is what we call "cascading input controls". There is no solution for this right now, but we are looking to package up some extensions to JasperServer you can add to do this. Sherman Jaspersoft Is there any news?...I have tried to use $P{LoggedInUsername} on a input control query.Query runs correctly, but every browser (Safari, Firefox, IE) gives same error. See image below.Update: this error occurs only on JS 3.7, it doesn't occur on JS 3.5.Post Edited by helyair at 08/30/2010 13:16Post Edited by helyair at 08/30/2010 13:38Post Edited by helyair at 08/30/2010 16:01 Link to comment Share on other sites More sharing options...
ramnik Posted August 30, 2010 Share Posted August 30, 2010 If this is abt cascading input control ..it is available as feature in JR Pro 3.7. , JS CE 3.7 and JS Pro 3.7.1 [ with many bug fixes ]Ramnik KaurSenior QA Engineer Link to comment Share on other sites More sharing options...
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