function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GtennentGtennent 

Can put field value names in a long/rich text field and have them display in Visualforce?

Here's what I'm trying to do. I work for a small nonprofit and I want to create a button that auto-generates a pdf thank you message for staff to print out and mail. Easy enough. I also want staff to be able to update and edit the text of that thank you, without having to learn to code, using pre-defined code pieces in their document. For instance, I want them to be able to write "Thank you for your {!Opportunity.Amount} gift..." and have it show up as "Thank you for your $50 gift..."

Here's my process so far: I put a long text/field on the campaign object where staff person can paste the letter text. Then in Visualforce, I call up this text field and display it. So far so good, kinda. 

My issue is that in the text of the Visualforce page it still says "Thank you for your {!Opportunity.Amount} gift...". If I use <apex:outputField ... /> instead it does the samething. It isn't displaying the information from the opportunity. If I put {!Opportunity.Amount} directly in my visualforce page it works just fine.

Here's the code for that section. Changing the escape doesn't help. 
<apex:outputText escape="false" value="{!Opportunity.Campaign.Ack_Letter_Text__c}"/>





Two questions:
  1. How can I put field values or apex code into a text field, and have it display properly when called in a Visualforce page?
  2. If the answer to 1 is no, then can you suggest a workaround that would make it easy for non-dev staff to update or create new letter copy?
Ajay K DubediAjay K Dubedi
Hi Gtennent,

you can use below tag to display richtext area in visualforce page.
 
<apex:inputtextarea label="RichText"  richtext="true" value="{!body}" 
     id="Body" cols="100" rows="15"/>

For more you can refer to below link:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_display_field_values.htm     

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi 
GtennentGtennent
Thanks for the response Ajay. I can get my text fields to display just fine. I'm not creating a form so the input text area doesn't work, instead I'm creating a pdf.

What I need to do is get field values written into the text field to display in visualforce. 

For example. I have a text field with the following text saved in it:
"Thank you for your {!Opportunity.Amount} gift..."

When I display the text field in visualforce I see the following:
"Thank you for your {!Opportunity.Amount} gift..."

What I want to see is this:
"Thank you for your $50 gift..."

How to I get it to say $50 not {!Opportunity.Amount}?
SVsfdcSVsfdc
use as below
"Thank you for your ${!Opportunity.Amount} gift..."