getting Salesforce ContentNote.Content from SOQL

914 views Asked by At

We are working with SOQL to interact with Salesforce. Consider the very simple query:

      select Id, Content, TextPreview, Field
      from ContentNote
      limit 100

Per their documentation ContentNote. Content should be the rich text -- but what w are getting back a URL pointing to the content. Which requires us to do n+1 queries.

The response we get looks something like:

{
  attributes: {
    type: 'ContentNote',
    url: '/services/data/v42.0/sobjects/ContentNote/asdfasdf0707234sdsdf'
  },
  Id: '0692L000008xwLMQAY',
  Content: '/services/data/v42.0/sobjects/ContentNote/asdfasdf0707234sdsdf/Content',
  TextPreview: 'please give jonathan a call'
}

Note we are leveraging jsforce for our API access.

Has anyone worked around this?

FYI

enter image description here

1

There are 1 answers

1
salesforceDev On
List<ContentNote> cn = [SELECT Id, Content, Title FROM ContentNote ];
for(ContentNote ecn : cn){
    String myString = ecn.Content.toString();
    String extractedText = myString.stripHtmlTags();
    System.debug(extractedText);
}