Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Change DataObject at the runtime
bcmp
<p>Much appreciated, if somebody share the ways to change the data object at the run time in the report. Based on the user, I need to change the data object as a data source.</p>
Find more posts tagged with
Comments
Clement Wong
<p>In the <em>beforeFactory </em>event of your report design, you can change the Data Object location and file name. Here's an example:</p>
<pre class="_prettyXprint _lang-">
importPackage( Packages.org.eclipse.birt.data.engine.api );
var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();
var de = DataEngine.newDataEngine( myconfig, null );
var dsrc = reportContext.getDesignHandle().findDataSource("Classic Models Data Source");
//var logger = java.util.logging.Logger.getLogger("birt.report.logger");
//logger.warning (dsrc.getDataMartURL());
//Example of setting
//dsrc.setDataMartURL('Data Objects/Classic Models');
var serverContext = reportContext.getAppContext().get("ServerContext");
// check to see if it's run on the server (BIRT Designer Pro or iHub)
//
if(serverContext.getVolumeName() != null) {
var theUsername = reportContext.getAppContext().get("ServerUserName");
dsrc.setDataMartURL("Data Objects/" + theUsername);
}
//logger.warning (dsrc.getDataMartURL());
</pre>
bcmp
<p>Report prints changed data object in the console but visualisation still uses the old data object. Attaching the sample for your observation.</p>
<p> </p>
Clement Wong
<p>There's a defect here, and it's not working as expected. Please open a case with Support and send them the same files in the post above so that they can log a ticket. You can ask if they can provide a fix for this in an upcoming release.</p>
<p> </p>
<p>Meanwhile, to workaround this issue, you'll need to specify an <em><strong>*invalid*</strong></em> Data Object file path or name. It seems that only when the Data Source is not a valid path or name that the datamartURL can be changed.</p>
<p> </p>
<p>To do this, go into the XML Source of the .rptdesign, find your Data Source definition and modify the value of the datamartURL by changing the path to an non-existent one.</p>
<pre class="_prettyXprint _lang-">
<property name="datamartURL">Data Objects/xxxDataObjectUSxxx</property>
</pre>
<p>Then beforeOpen code will work.</p>
<p> </p>
<p> </p>
<p>Please note that the other method of changing the datamartURL in the <em>beforeOpen </em>event of the data source doesn't appear to be working either. There is no workaround for it. I've filed a defect ticket for this.</p>
<pre class="_prettyXprint">
this.setExtensionProperty("datamartURL", "path/to/file);</pre>
Iloprtiz
As a gift we gave everyone 30 days or so at the start of the year to change their display name but it is not something we normally do.