frank.pompizzi Posted August 23, 2017 Share Posted August 23, 2017 We are in the process of converting from crystal reports to jasper. We have a report with address info and other fields on it. There is code that evaluates each address line and checks for not null and then adds it to a formula field with line feed. Since I am new with Jasper I am having a hard time converting this into jasper expression code. Can someone help us with this. I am trying to create a variable field with expression logic. Here is the Crystal code. Local StringVar outString;outString := {r_ald_header;1.dfi_name} + chr(13) + chr(10);if (not isNull({r_ald_header;1.address_line_1})) and ({r_ald_header;1.address_line_1} <> "") then outString := outString + {r_ald_header;1.address_line_1} + chr(13) + chr(10);if (not isNull({r_ald_header;1.address_line_2})) and ({r_ald_header;1.address_line_2} <> "") then outString := outString + {r_ald_header;1.address_line_2} + chr(13) + chr(10);if (not isNull({r_ald_header;1.dfi_city})) and ({r_ald_header;1.dfi_city} <> "") then outString := outString + {r_ald_header;1.dfi_city} + ",";if (not isNull({r_ald_header;1.dfi_state})) and ({r_ald_header;1.dfi_state} <> "") then outString := outString + " " + {r_ald_header;1.dfi_state};if (not isNull({r_ald_header;1.dfi_zip})) and ({r_ald_header;1.dfi_zip} <> "") then outString := outString + " " + {r_ald_header;1.dfi_zip};outString Link to comment Share on other sites More sharing options...
ghudson_1 Posted August 23, 2017 Share Posted August 23, 2017 JRXML reports use Java expressions by default, they aren't using something proprietary. And at the report element level you can also define them to use groovy instead of even javascript. So I recommend you grab a java developer or groovy developer and have them provide you syntax. Link to comment Share on other sites More sharing options...
frank.pompizzi Posted August 24, 2017 Author Share Posted August 24, 2017 After digging thru posts in the community I was able to figure out the syntax. This was my solution. thanks for you comment:($F{dfi_name}!=null?$F{dfi_name}+ "r"+"n": "")+($F{address_line_1}!=null?$F{address_line_1} + "r"+"n": "")+($F{address_line_2}!=null?$F{address_line_2}+ "r"+"n":"")+($F{dfi_city}!=null?$F{dfi_city}+ ", ":"")+($F{dfi_state}!=null?$F{dfi_state}+ " ":"")+($F{dfi_zip}!=null?$F{dfi_zip}:"") 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