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
ab84ab84 

Default value on rich text field

I have an visualforce page that uses a class extension to pre-populate some fields.

nws.NewsBody__c = 'Test default info'; works fine for text.

The NewsBody__c field is a rich text field.  How would I update my extension so that it includes images as the default value?


ab84ab84
Thanks, that was the site I used to write the code I have but it doesn't seem to mention how to include images or other rich text code?  I have the images as static resources in my org so all I need is a way to add the content as the default.  
Chidambar ReddyChidambar Reddy
Hi 

The following code is working for me in the extension class

public Listing__c listing{get;set;}
    public ListingPageCon(ApexPages.StandardController cnt) {
         
        listing = (Listing__c)cnt.getRecord();
       
       
       
        listing.testrichtext__c = '<img alt="User-added image" src= "https://chiddu-dev-ed--c.ap1.content.force.com/servlet/servlet.FileDownload?file=01590000003LPFw"></img>';


    }

I hope it will work for you too. replace the URL with your image url.

Thank you