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
ellsajames11.3892668100636045E12ellsajames11.3892668100636045E12 

Copy image from a Rich Text Area field to a field on a related object?

I am trying to pull an image from a Rich text area field on Account object to a field on a related custom object. Has anyone done this before or have any advise on the easiest way to do it?.

Basically, the data from the standard Account object is being pulled across (via formula fields) to a related custom object. I am struggling with pulling accross the image from a rich text area field.

Any ideas on best practice for doing this?
Vinita_SFDCVinita_SFDC
Hello,

The only possible solution i could list down is: http://salesforcetrick.blogspot.in/2013/06/converting-rich-text-area-fields-image.html

Apart from this, i doubt there could be another way to achieve this requirement.

Workaround: Store images in documents and access it from folder.
Gonzalo AbrunaGonzalo Abruna
For Images in Rich Text Area fields, the img link has the ID of the Salesforce field, so probably the issue is that when you copy your text from one field to another, the link is broken. If you find a way of replacing this in a formula (I'm affraid that you'll have to hardcode field ids), it should work ok.

This would be in apex code:
  String newValue = badValue.replace('feoid='+idOfSourceField, 'feoid='+idOfTargetField);
ericmonteericmonte
I actually had a similar situation where I need the Image from the RTF to display in my VF page. You can try pulling the SRC URL for the image using bunch of formulas.


Here is what i did for my VF page, and my RTF only contains Images no other text. You might want to see if this helps you out. I'll be glad to help you on this if you have questions.

            <!-- Retrieve the full length of the Article Image -->
            <apex:variable value="{!Len(News.newsKavObj.Article_Image__c)}" var="len"/>
            <!-- Find the src starts, then add 5 to retrieve the start of the SRC URL -->
            <apex:variable value="{!FIND("src", news.newsKavObj.Article_Image__c)+5}" var="mid"/>
            <!-- Do a mid function to get the start of the Src URL and the remaining URL based off the MID and Len Variables-->
            <apex:variable value="{!MID(news.newsKavObj.Article_Image__c, mid, len)}" var="source"/>
            <!-- Find the first " mark appearing in the source variable then using subtract 1 to find the MidEnd -->
            <apex:variable value="{!FIND("\"",source)-1}" var="midEnd"/>
            <!-- Now do a MID function that will take the first mid and midEnd, this will be the final Src URL for the Article Image -->           
            <apex:variable value="{!MID(news.newsKavObj.Article_Image__c, mid, midEnd)}" var="finalsrc"/>
ericmonteericmonte
sorry, you might want to create a simple Visualforce page to display this image. You can't reference RTF fields in a formula.
praveen murugesanpraveen murugesan
Hi All,

My scenario is to copy the richtextarea field from custom object to standard object(User) richtextarea (custom) field. 

I have done this by using cloning..

Here is the example of single record. You can use map for multiple record.

Xxx__c y = new Xxx__c();
     y = [select id,Image_xxx__c from Xxx__c where id=:yonalId];
   
     if(y != null)
     {
      Xxx__c pe = y.clone();          
      User user = [Select id, Image_uss__c from User where id=:userId];
      user.Image_uss__c = pe.Image_xxx__c;
      update user;
     }
Xxx__c: custom obj.
Image_xxx__c: richtextfield.

So now user will have image from Xxx__c's Image_xxx__c field.

Mark this as best answer if its helps.

Thanks.

Praveen Murugesan.