0

I pass the rich text field to the external system through the Rest API. When the external system clicks on the URL, I will be prompted to log in to salesforce. Is there any way to skip the login of salesforce and display the image directly?

I searched for relevant information and thought it was feasible.

example:https://stackoverflow.com/questions/51143107/how-to-access-rich-text-field-image-outside-salesforce

But there is no more detailed description. Can someone help me?

1

After my attempts, I found a solution.

  1. Create a site and in the "Public Access Settings" of the site, open the data permissions of the access object to the site profile.

enter image description here enter image description here 2. Replace the Org URL path in the rich text field with the site URL.

Such as: src="https://smartsocial--cpcs--c.documentforce.com/servlet/rtaImage?eid=701p0000000IWbc&feoid=00Np0000003zxfX&refid=0EMp00000009HnE"

Change to: http://cpcs-smartsocial.cs31.force.com/AccessImage/servlet/rtaImage?eid=701p0000000IWbc&feoid=00Np0000003zxfX&refid=0EMp00000009HnE

0

Try storing the image in a document instead and mark it as an Externally available image. You can then right click on the image to copy the publicly available url. It is generally in this format - https://jitendercoolguy-dev-ed--c.ap15.content.force.com/servlet/servlet.ImageServer?id=0159000000D0x2f&oid=00D90000000x5b3.

Just replace the id paramter with the document Id and the oid parameter with the org Id.

enter image description here

0

The suggestions here didn't work for me. I ended up rewriting the urls in the rich text on the fly when returning them from my api. In a manner so that they refer to my api which I use as image proxy through this SF API endpoint with an integration user: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_rich_text_image_retrieve.htm

private void rewriteImageUrls(RichTextRecord richTextRecord) {
    Document doc = Jsoup.parse(richTextRecord.getBody());
    doc.select("img").forEach(imgElement -> {
        try {
            URL originalUrl = new URL(imgElement.absUrl("src"));
            String newUrl = appEnv.getBackendUrl() + "/api/v1/rich_text_records/" + richTextRecord.getSfid() + "/image?refid="+ UrlUtils.getQueryMap(originalUrl.getQuery()).get("refid");
            imgElement.attr("src", newUrl);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    });

    richTextRecord.setBody(doc.outerHtml());
}

Far from ideal but it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.