I have files (ContentDocument) attached to a Lead on conversion I map the Lead to a custom object trough process builder. Is there a Id or field I can use to map the files attached to the custom object or do I need to write a trigger?
1You have to use trigger and create contentDocumentLinks for the new record– Pranay JaiswalJan 28, 2019 at 9:52
@PranayJaiswal Ok so there is no way to get the ContentDocumentId? If so please update your comment as an answer.– ThomasJan 28, 2019 at 10:07
Via trigger route, You can Query on ContentDocumentLink object to get all the files related to the any particular record. LinkedEntityId on ContentDocumentLink tells ID of the linked object. Can include Chatter users, groups, records (any that support Chatter feed tracking including custom objects), and Salesforce CRM Content libraries.
A sample query which you can modify as per the requirement:-
SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '0D5000000089123'
For getting the ContentDocumentID, You can store the ContentDocumentID in set variable and query on ContentDocument object. Link it with the new Custom Object record using insertion of ContentdocumentLink object.