I am trying to add a hyperlink to an Opportunity in the body of a note record. Something like this

note n = new note();
n.ParentId = {OpptyId};
n.title = 'Note from code';
n.body ='<a href=' +System.URL.getSalesforceBaseUrl().toExternalForm()+'/'+PrimaryId.get(op.Id)+' >'+'Closed Cleanup'+'</a> <br/>';
Insert n;

However, when note is created I see body-

<a href=https://ap8.salesforce.com/0060o00001BFCSZ>Closed Cleanup </a> <br/>

But I want body of note to have Closed Cleanup as clickable and should be redirecting on clicking to - https://ap8.salesforce.com/0060o00001BFCSZ

I took the reference from - How to use a Hyperlink function in apex class? which says Rich Text Area field can contain the hyperlink. If that's true , how do I add a hyperlink to a note record?


You are using the old Note object, which supports only plaintext in the body. See Note documentation.

If you want to use rich text in a note, you need to enable the new Notes functionality and then use the new ContentNote object. See ContentNote documentation

  • How do I add a hyperlink in the ContentNote? It will be great if you can share an example or so? Nov 11 '19 at 20:44

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.