Jump to content
We've recently updated our Privacy Statement, available here ×

Single field with diferent field-names


m8202

Recommended Posts

Hello

I'm using iReport in my work and I have some reports identical, but they have different field-names for the same field. For example: in a letter, the field Address is named "Address" in one case, and "Addr" in other case. Both are just the same field, but not named equal. How I can resolve it? I'm sure the answer will be obviuos, but I can't find it just now.

Thanks

M.

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

ok, i'll try to explain it better.

For instance: I have to do a report (a letter, for example) and I have 2 data sources with the following fields:

Data source 1: Name, Surname, Address, City, Country.

Data source 2: Name, Surname, Addr, City, Country.

I can't use the field "Addres" with the data source 2 and I can't use the field "Addr" with the data source 1.

So, how can I do if I want the report runs ok with both data sources?

 



Post Edited by m8202 at 09/25/2009 07:05
Link to comment
Share on other sites

m8202,

 

It seems like the same issue as if you said, "I have a column named 'Column1', but I want to refer to it as 'Col1' in my report." I don't see how iReport could handle this even in principle.

 

If your data source is SQL, you could create a view in Data source 2 that has the column names you want to use. If it's a non-SQL data source then maybe some variation on this idea could work.

 

Regards,
Matt

Link to comment
Share on other sites

You could, if they are mutually exclusive print them like this.

$F{Address}!=null?$F{Address}:$F{Addr}

this will print Address if it is not null otherwise it will print $F{Addr}.

 

Your report must know when datasource1 is active? You could also use a varable or a parameter to swap the fields withing the element.

ie $V{DS1}.booleanValue()?$F{Address}:$F{Addr}

DS1 is set to TRUE when you have Datasource1 active. You would need some logic to set this.

 

Also you could have a variable $V{THE_ADDRESS} then assign it something like this...

$F{Address}!=null?$F{Address}:$F{Addr}!=null?$F{Addr}:null

then just use the $V{THE_ADDRESS} on your report. NOTE if they are both null u will still get a null.

Ofcourse if your SQL returns a value into $F{Address} or $F{Addr} that is not a vaild addres, and is not null either, then you will need to check for that content instead of null... say when its an empty string.

 

luck!



Post Edited by walmillard at 09/29/2009 00:12



Post Edited by walmillard at 09/29/2009 00:13
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...