[rt-users] Retrieving CustomFields with RT-Jasper

Michael Keetman Michael.Keetman at qcn.com.au
Mon Apr 29 22:22:23 EDT 2013


Hi,

I have made some progress with this after a good night's sleep.

First of all, I pulled in a patch which exposes all the global fields (details here: https://github.com/bboksa/RT-REST/pull/1) (instead of just id, subject and timeworked)

Secondly, I spent time with the JRXML and a java debugger, and discovered the main problem is that the customFields is a hashmap supplied to the Reports server.  This needs to be dereferenced and cast to the appropriate class (RTCustomField) to access the values. 

An example:
Specification of the field:
<field name="customFields" class="java.util.HashMap"/>

Then when defining the text field in the report, this then needs to be cast to expose the customField value (in this case a custom field indicating the "Incident Start DateTime") like so:
<textField>
	<reportElement uuid="5e0163ad-3c25-4b20-b0d1-10bb957dd053" x="23" y="0" width="100" height="20"/>
	<textElement/>
	<textFieldExpression><![CDATA[((de.boksa.rt.model.RTCustomField)$F{customFields}.get("Incident Start DateTime")).getValue()]]></textFieldExpression>
</textField>

Hopefully this is understandable, and is helpful.  I am not a Java programmer by any means, so if anyone here can suggest a better method, I am all ears.

Regards, 

Michael Keetman

-----Original Message-----
From: ktm at rice.edu [mailto:ktm at rice.edu] 
Sent: Tuesday, 30 April 2013 2:51 AM
To: Ruslan Zakirov
Cc: Michael Keetman; rt-users at lists.bestpractical.com
Subject: Re: [rt-users] Retrieving CustomFields with RT-Jasper

On Mon, Apr 29, 2013 at 08:23:34PM +0400, Ruslan Zakirov wrote:
> On Mon, Apr 29, 2013 at 10:41 AM, Michael Keetman < 
> Michael.Keetman at qcn.com.au> wrote:
> 
> > Hello, ****
> >
> > ** **
> >
> > I am not entirely sure this is the right forum for this question, 
> > however the only other information I can find about RT-Jasper is in 
> > this and the Devel mailing lists.  ****
> >
> > ** **
> >
> > I have managed to install the RT-Jasper and RT-REST packages, and 
> > successfully run a report with the ID and Subject shown (both fields 
> > exposed directly) using Jasper Reports server, however I have had no 
> > luck getting any Custom Fields to return any data.  ****
> >
> > ** **
> >
> > Can anyone supply sample JRXML showing how this is done?
> >
> 
> Isn't it easier to let jasper talk to RT's DB directly?
> 
> 

Jasper can definitely talk to RT's DB directly very simply. The problem is that then you have to implement RT in the report tool. Using REST makes access trivial.

Regards,
Ken







More information about the rt-users mailing list