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?
1 Answer
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.