+ Start a Discussion
Anushka BansalAnushka Bansal 

check null condition for Rich text field

I want to check whether a Rich text field named as "Contact_Image" is blank or contains an image in a record.
If the field contains an image i want to display it on a vf page (using soql query in a custom controller)
but if it is blank i want to display an image from the static resources.
is it possible??
 

Best Answer chosen by Anushka Bansal
NagendraNagendra (Salesforce Developers) 
Anushka,

To check whether a Rich Text Area field is empty, use the LEN function, like:

LEN ( My_Rich_Text_Field ) = 0

Please let me know if this helps

Regards,
Nagendra.

All Answers

NagendraNagendra (Salesforce Developers) 
Anushka,

To check whether a Rich Text Area field is empty, use the LEN function, like:

LEN ( My_Rich_Text_Field ) = 0

Please let me know if this helps

Regards,
Nagendra.
This was selected as the best answer
Anushka BansalAnushka Bansal
but i dont understand what tag to use and also the proper syntax.
 
Lokesh KumarLokesh Kumar
HI Anushka.

Please try to use below code and format it accordingly.
<apex:image id="theImage" value="{!If(LEN ( My_Rich_Text_Field ) = 0, $Resource.Logo_UK, e.My_Rich_Text_Field))}" 
width="25" height="12"/>

FYI https://developer.salesforce.com/forums/?id=906F000000097mvIAA

Thanks
Lokesh