0

Salesforce Note content is stored in ContentVersion.VersionData as Base64. The LWC lightning-formatted-rich-text just displays BLOB(n bytes).

The SOQL in Apex looks like this:

notesList = [select Id,Title,TextPreview,VersionNumber,CreatedBy.Name,CreatedDate,VersionData
    from ContentVersion
    where isLatest = true
    and ContentDocumentId = : noteIds
    and FileType = 'SNOTE'];

The template HTML looks like this:

<template for:each={notes.data} for:item="note">
    <p key={note.Id}>{note.Title}-{note.TextPreview}</p>
    <lightning-formatted-rich-text key={note.Id} value={note.VersionData}></lightning-formatted-rich-text>
</template>

I'm developing a custom Notes control (LWC) to provide better functionality/features. I'm currently using a wired Apex method, which is returning the correct List of records.

Because Salesforce uses Base64 for rich text storge and they have a rich text formatting component, it seems natural that there should be a built-in solution, but I'm finding no information in the developer documentation.

1 Answer 1

0

The Rich Text component expects an HTML and is what the Note Content actually has, but you just need to decode the base64.

base64Decode(content).toString();
2
  • Thank you Javier. It's good to know the solution could be straightforward in some circumstances. I'm using a wired Apex class (static method) that returns a collection of ContentNote objects. I'm a C# developer... the code behind is still not so obvious to me. I would need to pass the blob to a function... not sure where to do the decode. Apr 19, 2021 at 23:18
  • Based on my C# .NET experience, what I'm doing in JavaScript "feels" sloppy. I don't just want to get by in JavaScript. I want to do it in a solid/supportable way. Apr 20, 2021 at 13:02

You must log in to answer this question.

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