Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Display username that execute the report
birtbeginner
<p>Hi, All</p><p> </p><p>I just started desinging report using birt and know nothing about either Java or Javascript.</p><p>I currently need to display the user name that executed the report, I've read several posts about it and have a rought idea that I need to write a Javascript to do it using something like:</p><p>reportContext.getAppContext().get("ServeruserName").</p><p>However, I don't know where to put this script and how to call it later</p><p>can anyone give me a stepwise guidance?</p><p>Thank you so so much!</p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p><p> </p><p>It really depends what you intend to do with the Username value. If you just want to display it in a report, the simplest way is to drop a Label component in your report and add the following line to the onRender method:</p><p> </p><p>this.text = reportContext.getAppContext().get("ServerUserName");</p><p> </p><p>Keep in mind that:</p><p>1. ServerUserName works only with the commercial version of BIRT, when you run the report on either iServer or iHub;</p><p>2. it will return "anonymous" when you run it from the Designer.</p><p> </p><p>Hope this helps,</p><p> </p><p>P.</p>
birtbeginner
<div>Thank you for the reply! Richer</div><div>Do you mean that in one of the cell inserting a label and then click on the script, from the drop down list select onRender and type this.text = reportContext.getAppContext().get("ServerUserName"); in the script window</div><div>That's what I did but previewing the report yields nothing in the label place</div>
pricher
<p>Hi,</p><p> </p><p>As I mentioned in my previous post, <em>reportContext.getAppContext().get("ServerUserName")</em> will return <em>null </em>if you are not running on Actuate BIRT iHub (i.e. the commercial release of BIRT)</p><p> </p><p>If you are running BIRT Open Source and the runtime engine, you will have to capture the user name in a session variable and retrieve it in you BIRT report. For example, if you have a JSP that stores the user name in a sesion variable called <em>userName</em>, you can use the following code in the <em>onRender </em>method of a label to retrieve the <em>userName </em>value:</p><p> </p><p>var httpRequest = reportContext.getHttpServletRequest();
var session = httpRequest.getSession();
var user = session.getAttribute("userName");
this.text = "User is " + user;
</p><p>I have attached an example with JSP pages and a report design. Copy the files to the root of your app Server and run go.jsp</p><p> </p><p>Hope this helps,</p><p> </p><p>P.</p>
DenisG
<p>Hi, Pierre! I have the same issue with username in report. In my case I have OpenText Content Server 10.5 on TOMCAT and BIRT 4.5.0. Could your decision help me and if so how I can implement it?</p>
pricher
<p>Hi,</p>
<p> </p>
<p>If you are running BIRT Open Source in your Content Server environment, you cannot use <span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><em>reportContext.getAppContext().get("ServerUserName")</em> to return the user name. That syntax only works when you run BIRT from the Open Text Actuate iHub, and as far as I know, iHub is not integrated with OT Content Server.</span></p>
<p> </p>
<p><span>When using BIRT Open Source, your only option is to work with </span><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><em>reportContext.getHttpServletRequest()</em> and from the object returned call </span><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><em>getSession()</em> to work with session attributes that <em>could </em>store user information.</span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">I am attaching a BIRT report example that illustrates retrieving data from the HTTP session. When you run the report, you will get a bunch of property names and their values. These properties have been extracted in the beforeFactory Event Handler of the report and stored in a scripted data set. This should give you some directions on how to proceed in your particular case.</span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Hope this helps,</span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">P.</span></p>
DenisG
<p>Pierre,</p>
<p>Your report works fine but unfortenutely there is no information about OpenText user which ran report.</p>
pricher
<p>Denis,</p>
<p> </p>
<p>And that is fully expected! The only way you can have BIRT retrieve user info from OT Content Server is to find out if Content Server stores user info in a session attribute that you can then retrieve using session.getAttribute(). </p>
<p> </p>
<p>P.</p>
bmark
<p>Hello Pierre,</p>
<p> </p>
<p>my reports are running in iHub 16. You know I can setup eMail and Description per user in their profiles. Is it also possible to fetch email and description for the current logged in user in the report like I can do with "ServerUserName"? What are the keys?</p>
<p> </p>
<p>Thank you in advance</p>
<p> </p>
<p>Benjamin</p>
pricher
<p>Hi,</p>
<p> </p>
<p>As far as I know, ServerUserName simply returns the user name. If you want to get other properties of the current user, you will need to write some IDAPI code to get the user object from the iHub volume.</p>
<p> </p>
<p>P.</p>