m8202 Posted September 24, 2009 Share Posted September 24, 2009 HelloI'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.ThanksM. Link to comment Share on other sites More sharing options...
svenn Posted September 24, 2009 Share Posted September 24, 2009 Your question is not clear. Are you saying you have similar reports that report off of different tables and the address is named differently in the different tables? Link to comment Share on other sites More sharing options...
m8202 Posted September 25, 2009 Author Share Posted September 25, 2009 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 More sharing options...
mdahlman Posted September 28, 2009 Share Posted September 28, 2009 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 More sharing options...
walmillard Posted September 29, 2009 Share Posted September 29, 2009 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}:nullthen 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:12Post Edited by walmillard at 09/29/2009 00:13 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now