0

I have Custom Object that contains many Notes for each record.I want to retrieve the latest Note inserted for all the Records.

List<CustomObject__c> = [select (select Body from Notes order by Id desc Limit 1) notes,Id from CustomObject__c];

The above Query gives me the Latest Note but it contains Body like

(Note: ParentId:.... Body :...... Id: .....)

I want to show Body of latest Note in apex:outputText

and i also tried below query which gives only Body of Note but not Latest Inserted.

List<Note> notes = [Select Body from Note where ParentId in(select Id from CustomObject__c)];

Thanks in advance

2 Answers 2

0

Have you tried this?

List<Note> notes = [Select Body from Note where ParentId in(select Id from CustomObject__c) order by Id desc Limit 1];
1
  • Thanks for response. This will give me only one Note for all the records not for each record. Aug 22, 2014 at 8:05
0

I got the solution

List<Note> notes = [Select Body from Note where ParentId in(select Id from CustomObject__c) order by ParentId,CreatedDate desc];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .