function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EldonEldon 

Cannot query the field 'TextPreview' from 'ContentNote' object in Apex class

Hi All,

I am trying to display the notes associated with a custom object record. I have the correct ContentNote Ids but when I give the following SOQL in an apex class, I am receiving an error.
[SELECT Id,Title, Content,CreatedDate, TextPreview FROM ContentNote WHERE Id IN: contentIds]

No such column 'TextPreview' on entity 'ContentNote'. If you are attempting to use a custom field, be sure to append the '__c' 

The same SOQL works fine in the query editor though. I am able to the see the correct records and the TextPreview field in console.
I am trying to display these notes in a VF page and if I use the field 'Content' in the page its displayed as below:
          core.filemanager.ByteBlobValue@19c5beb6

Is there any way to display the text value of the notes in VF page?

Thanks in advance
Eldon K
 
Best Answer chosen by Eldon
AnudeepAnudeep (Salesforce Developers) 
Hi Eldon, 

As long as your apex class is on version > 35 and the field is visible to the user who is querying it you should not see the error

I recommend checking this post to learn more

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Eldon, 

As long as your apex class is on version > 35 and the field is visible to the user who is querying it you should not see the error

I recommend checking this post to learn more
This was selected as the best answer
EldonEldon
Hey Anudeep,

The VF page and apex class API versions were < 35. Updating it solved the issue. Thanks for the quick response.

Regards
Eldon K