+ Start a Discussion
vivek ravivivek ravi 

how to write the soql query for fetching the notes and attachment related list

i have a custom oject name has brand and i need show  the notes and atachment records in the new window i already done with standard controller but nw i need to use the extension controller how can i fetch that with soql query

Hello Vivek,

 As per your requirment ,we can write your query like this

first you need get customobjectId by using Apexpages.currentpages().getparameter().get('Id');
for note :select id from note where parentId=:customobject Id;
in same way for Attachment:select id from attachment where parentId=:customobject.Id;

You may get all notes and attachments for particular record according to id which ur passing.

If you satisfy with Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
SFDC Certified Developer

RIyas BasheerRIyas Basheer
Hi Vivek,

 You can try like this
for(myObj__c fp :[SELECT Id, (SELECT Id FROM Attachments) FROM myObj__c LIMIT 1]){