maruthu.u Posted September 26, 2019 Share Posted September 26, 2019 Hi,How to make elseif condition in jaspersoft studio. Link to comment Share on other sites More sharing options...
C-Box Posted September 27, 2019 Share Posted September 27, 2019 Just use the short java syntax for that:$F{YourFieldX}.equals("Microsoft") ? "BigButBuggy" : "OthersArePerhapsBetter" [/code]of course you can also build nested if-then-elses (use brackets for more readability):$F{YourMoneyBag} < 0 ? "Ooops negative is bad" : ( $F{YourMoneyBag} <= 100 ? " ok positive but could be more": "more than 100 - well done" )[/code]hth + regardsC-Box Link to comment Share on other sites More sharing options...
maruthu.u Posted September 27, 2019 Author Share Posted September 27, 2019 it's also great method,$F{result}.equalsIgnoreCase("approved") ? "Approved" :($F{result}.equalsIgnoreCase("not_suitable") ? "Not suitable" :($F{result}.equalsIgnoreCase("hold") ? "Hold" :($F{result}.equalsIgnoreCase("production_trial") ? "Go to production trial":"" )))Finaly when Not satisfied any condition display "" empty.i'm using this method to complete the process. Link to comment Share on other sites More sharing options...
C-Box Posted September 27, 2019 Share Posted September 27, 2019 Be aware that if your Field named "result" is in java or from your query just null then you will get a NullPointerException that is internally ignored by JasperReports by default. :-O Then your expression won't work as expected!So that's why it's (always) better to turn the equals comparisons to make it null-safe:"approved".equalsIgnoreCase($F{result}) ....[/code];-)Or just use the StringUtils from Apache, that are also more "null-resistant" and also available in JasperReports classpath.Just my two centsC-Box 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