1

I am using the following Salesforce API to generate a case comment.

POST /services/data/v39.0/sobjects/CaseComment HTTP/1.1
Host: *******.my.salesforce.com
Content-Type: application/json
cache-control: no-cache
Postman-Token: f307fe07-8f81-4653-adca-42f6880b28cd

{
    "ParentId": "5002500000*********",
    "CommentBody": "Go here and check the best website ever: <a href=\"http://www.google.com\">Click me</a>",
    "IsPublished": "false"
}

I was wondering if is possible to put a hyperlink or html code in the CommentBody and make Salesforce render it. Using the GUI I am able to create an hyperlink but using the API, I was not able to.

Note: API taken from here: https://developer.salesforce.com/docs/api-explorer/sobject/CaseComment

The following image I have posted the first comment using the GUI the following two comments were posted using the API. Comment case post using GUI/API

2
  • why can't you just use the API and set the comment body to ...http://www.google.com/..? The browser or email client will render the URL as clickable
    – cropredy
    Jun 10, 2019 at 14:31
  • Unfortunately when I do that, the comment on the case just shows the URL as a plain text, rather than making it clickable.
    – Raul Junc
    Jun 11, 2019 at 8:02

2 Answers 2

1

Your screenshot looks like Chatter posts, not CaseComments. To post a rich-text Chatter post, you need to use the Chatter API's rich-text comment function.

The CommentBody field on CaseComment is a text area, not rich text, so you can't insert HTML into it.

0

Just figured this out myself, you're looking for the object FeedItem instead of CaseComment:

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feeditem.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .