kry_1 Posted March 28, 2023 Share Posted March 28, 2023 HelloLets say that I have two fields, $F{INTRODUCTION} which value is "Ny name is $F{NAME}, and I am from Germany" and F${NAME} which value is "Franz Beckenbauer".Is it possible for Jasper Reports to evaluate the NAME field in the INTRODUCTIONS field, so that it says "My name is Franz Beckenbauer, and I am from Germany"? Link to comment Share on other sites More sharing options...
anish.rai Posted March 28, 2023 Share Posted March 28, 2023 Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times. Link to comment Share on other sites More sharing options...
kry_1 Posted March 29, 2023 Author Share Posted March 29, 2023 Any news on this? :) Link to comment Share on other sites More sharing options...
Solution Tirupathi Mangalarapu Posted March 29, 2023 Solution Share Posted March 29, 2023 You can define your text-filed expressions in the following format: "My name is "+ $F{NAME}+", and I am from Germany" Link to comment Share on other sites More sharing options...
kry_1 Posted March 30, 2023 Author Share Posted March 30, 2023 Thanks for the answer, @JRS-SE.Yeah, I know that I can concatenate two fields together. My problem is that the data is defined in sql, so one cell called field_1 might have the content: "My name is $F{reference_to_another_cell_that's_written_in_plaintext}, and I am from Germany", so I can't concatenate the fields together, because it's hard coded in the actual data. We're migrating from another report generator, where it was possible to create references like <<this>> and the generator would read the tag and replace it with value from what the tag was referencing. I'm trying to find if it's possible to somehow keep that functionality in Jasper Reports. I know that I can create some convoluted find a replace string mechanics when defining the text fields, or I can create a scriplet that can handle that functionality. I wondered if that kind of functionality was already in place. Link to comment Share on other sites More sharing options...
Tirupathi Mangalarapu Posted April 12, 2023 Share Posted April 12, 2023 Have you looked into the string functions in the expression editor? Does this help?$F{Title}.replace( char, char )$F{Title}.replaceFirst( String, String )$F{Title}.replace( CharSequence, CharSequence )$F{Title}.replaceFirst( String, String )$F{Title}.split( String )$F{Title}.substring( int, int ) Link to comment Share on other sites More sharing options...
kry_1 Posted April 12, 2023 Author Share Posted April 12, 2023 Hi JRS-SE Yes, I looked first a the string functions but I thought that there might have a more neat way to do that. My solution was to use a Scriptlet that uses some string replace methods, and calling that Scriptlet in the field. Then the field won't be filled with hard to read function calls. Thanks for the guidance. :) Link to comment Share on other sites More sharing options...
kry_1 Posted April 12, 2023 Author Share Posted April 12, 2023 I found out that this isn't possible. The closest thing I got to this was by creating a Scriptlet that takes a parameter, and uses that parameter to replace parts of the string, and then returns the new string. Link to comment Share on other sites More sharing options...
Tom C Posted April 14, 2023 Share Posted April 14, 2023 JasperReports engine (JRL) is a Java application, not a scripting application, therefore you cannot use string substitution directly in the text string.What you can do, however is to use Java string substitution class method to achieve your goal:$F{INTRODUCTION}.replace("$F{NAME}", $F{NAME}) 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