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)
Fetch Windows Logged User Name To Report
jegan
Hi all,
I would like to add a PRINTER BY field in report where this field should fetch username of person currently logged to Windows. How can I do this? Tried googling around but couldn't find anything related to my issue. Hope someone can assist me on this. Thanks in advance.
Find more posts tagged with
Comments
kclark
Add the following to beforeFactory()<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.lang);
reportContext.setPersistentGlobalVariable("userName",System.getProperty("user.name"));
</pre>
<br />
Then this code to a dynamic text box<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getPersistentGlobalVariable("userName");
</pre>
jegan
Hi Clark,<br />
<br />
Thanks for the codes.<br />
<br />
Some how the codes works; only in designer mode. But when I execute the report from BIRT Viewer, it just display <strong class='bbc'>SYSTEM</strong> as username, not my actual username in Windows. Same scenario for other users executing the report from BIRT Viewer.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="110611" data-time="1350483514" data-date="17 October 2012 - 07:18 AM"><p>
Add the following to beforeFactory()<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.lang);
reportContext.setPersistentGlobalVariable("userName",System.getProperty("user.name"));
</pre>
<br />
Then this code to a dynamic text box<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getPersistentGlobalVariable("userName");
</pre></p></blockquote>
kclark
That code is only going to show the username of the host machine. If the report is ran on the server but displayed on your desktop it is going to show the server information.
jegan
HI clark,
So how do i get the username of a person running the report instead getting server info?