Enter the content of another field inside a rich text field
Hello again. I'm just ending the development of a custom application that needs to print and export some rich text fields with lots of text. What I need is some kind of "data merge" inside a rich text field, to enter some dynamic data. For example, in a long rich text field for a contract, I want to show the client name, age and address.
Is there some "hidden" HTML code to insert a placeholder and replace it with the correct information?
Meanwhile... I know I can use an strategy like this:
- Create "custom fake" placeholders inside the rich text field (RTF1), like [field1], [field2], etc.
- Create a button and another Rich Text Field (RTF2) that will contain the resulting text
- Inside the button, create a custom script that replaces each "fake" field placeholder by the real field content, using the replace() and/or the replace() functions and writing the resulting text inside the RTF2 field
But with this solution, the user will need to always click the button or, if you don't want to create a button, insert the same script in all the fields that, when modified, will alter the content of the Rich Text Field. For example, each time you modify the client's name or age, the rich text field will be recalculated.
If anyone knows a better/cleaner/less cumbersome solution...
There are smarter people who can answer this better, but there is an example of what you can do:
let xFName := Volunteer.FName; let xLName := Volunteer.LName; html("Hello <h2>" + xFName + " " + xLName + "</h2>: " + Body + "")
Lines 1 and 2 pulls data from a reference field.
Lines 3 and 4 is the html content. You see you have to get out of the HTML quotes and use the + signs to tell Ninox to use fields or variables. Body is a Rich Text field.
As you can see the Rich Text field loses it's formatting when put in a formula. Maybe someone has a better way.