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
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

 
Sri549Sri549
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,
Srinivas
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]){
	system.debug(fp.Attachments[0].id);
}
Thanks,
Riyas