+ Start a Discussion
The KnightThe Knight 

To get the list of Notes & attachments through SOQl

We have a requirement to display notes&Attachments of a particular record in Ext Js grid. How can we get the notes & Attachments of a particular record through soql and display it as a comma seperated hyper links in a table.

 

    Record              Notes&Attachments

     rec1                     n1,a1

     rec2                     n2,a2

 

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

I believe you can only query the notes and attachments as a related list, not directly, something like this:

 

 

String curroppid='0064000000AJzIIAA1'; Opportunity oo = [Select o.Name, o.Id, (Select Id, IsNote, Title From NotesAndAttachments) From Opportunity o where o.id=:currOppid limit 1]; List<NoteAndAttachMent> n=oo.NotesAndAttachments; //process the list for each record to recreate a URL back to the Note or Attachment, or, depending on your need, different URLs for notes and attachments.

 

 

 

All Answers

JimRaeJimRae

I believe you can only query the notes and attachments as a related list, not directly, something like this:

 

 

String curroppid='0064000000AJzIIAA1'; Opportunity oo = [Select o.Name, o.Id, (Select Id, IsNote, Title From NotesAndAttachments) From Opportunity o where o.id=:currOppid limit 1]; List<NoteAndAttachMent> n=oo.NotesAndAttachments; //process the list for each record to recreate a URL back to the Note or Attachment, or, depending on your need, different URLs for notes and attachments.

 

 

 

This was selected as the best answer
The KnightThe Knight
Thanks Jim. It worked.