Print this page

Users can't see images when accessed through portal

Knowledge Article Number 000176739
Description

Scenario -
User has a website which connects to Salesforce.com using the Soap API (enterprise.wsdl).
User is querying for a rich text area custom field which is used to upload images.

For instance, here is a SOQL Query where resolution is rich area text field used to upload images -
SELECT resolution FROM myArticle WHERE ArticleNumber= '000001' AND PublishStatus='Online' AND IsLatestVersion = true AND Language='en_US'

Issue -
The above API query result is a html img element (with src) to the actual image , which resides on Salesforce internal servers.

When the user accesses this record on the portal, images do not display.
When the user logins in Salesforce and refreshes the portal page then images appear.

Resolution Resolution -
This is working as designed.
Attempting to use the image url from an unauthenticated browser session results in the issue.
Images in the rich text area fields are meant to be "Salesforce internally available only" by default.
There is no api that will allow to retrieve the body\ actual file of an image file from a rich text area field.

Workaround -
1) Consider to switch to using a "file" field type instead of rich area text field and put your images there.
Or
Put your images in the documents object.

Both allow you to get the actual body of the document via the API query call.
More information about this API query call can be found here-http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_document.htm

Info on file field, Page 5 -
https://help.salesforce.com/help/pdfs/en/salesforce_knowledge_implementation_guide.pdf

2) If you were doing this with Articles in Salesforce, articles can be retrieved via the REST API.
http://www.salesforce.com/us/developer/docs/knowledge_dev/index_Left.htm#StartTopic=Content/knowledge_REST_retrieve_article_version.htm


Make your articles publicly available, which makes them accessible via force.com sites.
The basics are:-
  1. Create a Force.com Site
  2. The Public Access Settings for the site must allow access to the Knowledge Article Type object
  3. The site "Public Access Settings" must allow access to the Knowledge Article’s Type fields containing the rich text\images
  4. For the Knowledge Settings, enable "Allow users to share articles via public URLs"
  5. Publish your articles with the "Public Knowledge Base" channel selected.

Once this is done, you would need to then take the returned img src from your API query call, and substitute the domain there with the public site domain name.

So, if your force.com site access url is:
http://mySite.force.com,
you will change your img src in example provided:
//////////////////////
FROM (internal access only)
https://c.<instance>.content.force.com/servlet/rtaImage?eid=<ka0....>&feoid=<00N....>&refid=<0EM.....>

TO (Public site access)
http://mySite.force.com/servlet/rtaImage?eid
=<ka0....>&feoid=<00N....>&refid=<0EM.....>
//////////////////////





promote demote