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)
Copy Grid With Dynamic Script
felipesodre
<p>Hy boys,</p>
<p> </p>
<div>I have a report parameter that receives the amount of labels that you want to print, I decided to copy the contents of a grid within the table dynamically according to this parameter informed. </div>
<div> </div>
<div>But I get null pointer exception could you help me? </div>
<div> </div>
<div>
<pre class="_prettyXprint _lang-js _linenums:0">
importPackage(Packages.com.ibm.tivoli.maximo.report.script)
var mxReportScriptContext = MXReportScriptContext.initialize(reportContext);
mxReportScriptContext.setDefaultLogLevel("DEBUG");
mxReportScriptContext.setDefaultLogFile("c:/temp/etiquetas.log");
//get a reference to the ElementFactory
var elementFactory = reportContext.designHandle.getElementFactory();
//Copy Dynamic
var scriptLogger = mxReportScriptContext.getReportScriptLogger();
//scriptLogger.debug(reportContext.getDesignHandle().getElementByID(4963));
var mytable = reportContext.getDesignHandle().getElementByID(4963);
var mydetail = mytable.getDetail( ).get(0);
var tcell = mydetail.getCells().get(0);
//grid = elementFactory.newGridItem(null, 1,1);
var grid = reportContext.getDesignHandle().getElementByID(2278);
tcell.getContent().add(grid);
</pre>
</div>
<p>View attach layout.</p>
<p> </p>
<p>Thanks.</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>If I understand your problem, you want to dynamically create a certain number of labels based on an input parameter. Instead of attempting to modify the report design, a simpler approach (in my opinion...) would be to</p>
<p> </p>
<p>1. create a Scripted Data Set that will have as many rows as indicated by the input parameter;</p>
<p>2. create a Table that is bound to that Scripted Data Set</p>
<p>3. put the Grid that contains your label inside the detail row of the table created in step 2.</p>
<p> </p>
<p>Attached is a simple design that shows how it works. By default, it will display 5 times the number, name, and city of one customer. The only script added is in the <em>open </em>and <em>fetch </em>methods of the Scripted Data Set.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>