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)
How to run the report in BIRT Designer that has iHub API
jkamaraj
<p>Hi, I have the following iHub API code to retrieve the user roles in the onPrepare method.</p>
<p> </p>
<p> </p>
<p>userRoles = reportContext.getAppContext().get("ServerContext").getUserRoles();</p>
<p>reportContext.getAppContext().get("ServerContext").appendToJobStatus("The user roles: " + userRoles + "\n");</p>
<p> </p>
<p>This runs fine when the report is run in the server. However, when run in designer I get this error:</p>
<p> </p>
<p>TypeError: Cannot call method "getUserRoles" of null</p>
<p> </p>
<p>How can I change the code to check if the report is running on the designer and if so, do not make the getUserRoles() call?</p>
<p> </p>
<p>Thanks.</p>
<p>Raj</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi Raj,</p>
<p> </p>
<p>You are probably running your report in BIRT Designer Open Source. In that case, it is normal that get("ServerContext") returns null. The following code should work for you:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">serverContext = reportContext.getAppContext().get("ServerContext");<br>
if (serverContext != null) {<br>
userRoles = serverContext.getUserRoles();<br>
reportContext.getAppContext().get("ServerContext").appendToJobStatus("The user roles: " + userRoles + "\n");<br>
}<br>
else<br>
reportContext.getAppContext().get("ServerContext").appendToJobStatus("Running in the designer");</span></p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>