直接抽出するのは難しいのでApexバッチで取引先責任者にマークをつけて、あとはレポートで対応することとします。
I would like to export contacts with notes
public class BAT_findNote_Contact implements Database.Batchable<sObject> {
// *******************************************************************************************
//
// BAT_findNote_Contact bat = new BAT_findNote_Contact();
// ID jobId = Database.executeBatch(bat);
//
// ********************************************************************************************
public Database.QueryLocator start(Database.BatchableContext BC) {
// collect the batches of records or objects to be passed to execute
String query = 'Select Id From Contact WHERE isNote__c =False ';
System.debug('******** query ' + query);
return Database.getQueryLocator(query);
}
public void execute(Database.BatchableContext BC, List<Contact> conList) {
System.debug('******** comList ' + conList);
Set<Id> ConIdSet = new Set<Id>();
for (Contact c : conList ){
ConIdSet.add(c.Id);
}
system.debug('### ConIdSet ############ ----> '+ ConIdSet.size() );
List<ContentDocumentLink> CDLList = [SELECT Id,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId =: ConIdSet ];
system.debug('### CDLList ############ ----> '+ CDLList.size() );
List<Contact> updateContactList = new List<Contact>();
for (ContentDocumentLink CDL : CDLList ){
Contact con = new Contact();
con.Id = CDL.LinkedEntityId;
con.isNote__c = True;
updateContactList.add(con);
}
try {
system.debug('### updateContactList ############ ----> '+ updateContactList.size() );
if(updateContactList.size() > 0) update updateContactList;
} catch(Exception e) {
System.debug(e);
}
}
public void finish(Database.BatchableContext BC) {
}
}