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
Paula Kern 4Paula Kern 4 

Soql statement to get the notes for an opportunity lightning

I'm trying to report on the notes that were attached to an opportunity in LEX.  Can someone please share the soql to do this or can it be done.  Many thanks
NagendraNagendra (Salesforce Developers) 
Hi Paula,

May I suggest you please find the sample code below and tweak it as per the requirement.
List<opportunity> lstofOppWithNotesAttachment = [SELECT Id, Name,
(SELECT Id, Title FROM Notes),
(SELECT Id, Name FROM Attachments) FROM opportunity];
Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
Paula Kern 4Paula Kern 4
Thank you for the reply.  However I am using Enhanced Notes so therefor ContentNote object through ContentDocumentLink object.  I cannot get from contentdocument to contentNote