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)
Problem copying Report Item to another Report
keithpower
Hi all,
I've got some reports which each use Report Items from a library. I've written an application that lets a user select some of these reports and then combines the Report Items from these reports into one big report. I'm posting here because of a problem I ran into that took me quite a while to get around, it might save someone else some time.
You can copy items from one report design to another easily enough. You'll need to be using the Design API of course, that's documented well enough. Here's how to copy the report items:
for(int i=0;i<srcReport.getBody().getCount();i++) {
templateReport.getBody().add(srcReport.getBody().get(i).copy().getHandle(templateReport.getModule()));
}
The problem with this is it doesn't copy information about what component each item extends, if any, which means the produced report is generally broken.
You might then try to copy with:
DesignElementHandle toAdd = srcReport.getBody().get(i).copy().getHandle(templateReport.getModule());
toAdd.setExtends(srcReport.getBody().get(i).getExtends());
templateReport.getBody().add(toAdd);
but you'll find getExtends returns null for some reason, even though the debugger shows the extendsRef variable is set with the correct information.
Here's a way I found to get the information out and set it on the copy:
DesignElementHandle toAdd = srcReport.getBody().get(i).copy().getHandle(templateReport.getModule());
toAdd.setProperty(IDesignElementModel.EXTENDS_PROP, srcReport.getBody().get(i).getProperty(IDesignElementModel.EXTENDS_PROP));
templateReport.getBody().add(toAdd);
Hope this saves someone some heartache. And if you've got any better way of accomplishing this, please post it here.
cheers,
Keith
Find more posts tagged with
Comments
There are no comments yet