I am looking to export only case comments and notes related to particular standard and custom objects. Ex: All CaseComments for cases of a particular record type. All notes for a custom object with a particular field value.
I know there are currently multiple AppExchange and external products out there that currently do this, but I am looking to complete this task myself.
What I am thinking is use the Bulk Api/Data Loader to query and download CaseComments and Case with a WHERE clause to that identifies that cases by the criteria needed. Now I have an export of Case Ids and now I need a way to use this list of Cases Ids as the filter criteria on CaseComments to generate a list of only CaseComments related to those particular cases.
My current thought process is to utilize Node or Python to do this parsing and file generation, but I wanted to get some other ideas on how this might best be accomplished.
Code Based on Suggestions Made in Comments:
List<Case> caseList = new List<Case>();
List<CaseComment> caseCommList = new List<CaseComment>();
List<Note> noteList = new List<Note>();
caseList = [select Id from Case LIMIT 600];
caseCommList = [select id, parentId, commentbody from casecomment where parentId in (select id from Case where Id =: caseList)];
noteList = [select Id, parentId, Title, Body from Note where parentId in (select Id from Case where Id =: caseList)];
system.debug(caseCommList);
system.debug(noteList);
For the note query I was able to make the following work, but I am curious why the above does not function for notes:
List<Contact> contactList = new List<Contact>();
List<Note> noteList = new List<Note>();
List<String> contactIdStringList = new List<String>();
contactList = [select Id from Contact LIMIT 25000];
for (Contact c : contactList) {
contactIdStringList.add(c.Id);
}
system.debug(contactIdStringList);
system.debug(contactIdStringList.size());
noteList = [select id, parentId, Title, Body from Note where parentId =: contactIdStringList];
system.debug(noteList.size());
system.debug(noteList);
ContentDocumentLink
in Python.select id, parentId, commentbody from casecomment where parentId in (select id from Case where recordtype.developername = 'Foo_Bar')
ParentId
field onNote
is polymorphic - it doesn't just point to Case. That apparently is enough to break that particular subquery formulation.