On Lead conversion I also create a new object to which I map several fields of the lead trough processbuilder. I also want to pass the files from the lead to the new custom object. I am trying to do a query on lead and pass this to the new record Id but I am stuck on linking the content document id which I want to use as a trigger.
See:
List<ContentDocumentLink> ContDocLinksLead = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '00Q1X000001BxVmUAK'];
system.debug('ContDocLinksLead: '+ContDocLinksLead);
ContentDocumentLink LinkList = new ContentDocumentLink();
for(ContentDocumentLink Link: ContDocLinksLead){
Link.ContentDocumentId = ContDocLinksLead.ContentDocumentId;
Link.LinkedEntityId = 'a001X000000k7oSQAQ';
link.ShareType = 'V';
link.Visibility = 'AllUsers';
LinkList.add(Link);
}
Insert LinkList;