Created
May 28, 2020 03:52
-
-
Save swapnilshrikhande/73eb055a3f46a69c90f770366dc990ed to your computer and use it in GitHub Desktop.
Cloning Related Files, Here relating files from related case record to lead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AttachFile on Lead (after insert) { | |
List<ContentDocumentLink> cdeInsertList = new List<ContentDocumentLink>(); | |
System.debug('line3'); | |
Map<Id, Id> caseId2 = new Map<Id, Id>(); | |
for(Lead ldItr : Trigger.New) { | |
caseId2.put(ldItr.Case__c, ldItr.Id); | |
} | |
System.debug('line8'); | |
for(ContentDocumentLink cdl : [SELECT | |
ContentDocumentId,Id, | |
IsDeleted,LinkedEntityId, | |
ShareType,SystemModstamp, | |
Visibility | |
FROM | |
ContentDocumentLink | |
WHERE | |
LinkedEntityId IN :caseId2.keySet()]){ | |
ContentDocumentLink newCDE = cdl.clone(false, true, false, false); | |
newCDE.LinkedEntityId = caseId2.get(cdl.LinkedEntityId); | |
cdeInsertList.add(newCDE); | |
System.debug(newCDE); | |
} | |
insert cdeInsertList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment