Created
August 3, 2023 10:19
-
-
Save Sunil02kumar/b8358ef287d5637fda317a2b30aad242 to your computer and use it in GitHub Desktop.
Script to generate URL for download all files related to any record
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
string parentRecordId='0012800001IrqlyAAB'; | |
string orgbaseUrl=URL.getSalesforceBaseUrl().toExternalForm(); | |
string downloadAllFileUrl=orgbaseUrl+'/sfc/servlet.shepherd/version/download'; | |
List<string> contentVersionIdList = new List<string>(); | |
for(ContentDocumentLink cdl:[SELECT ContentDocumentId,ContentDocument.title,ContentDocument.LatestPublishedVersionId FROM ContentDocumentLink where LinkedEntityId =:parentRecordId]){ | |
contentVersionIdList.add(string.valueof(cdl.ContentDocument.LatestPublishedVersionId)); | |
} | |
downloadAllFileUrl = downloadAllFileUrl +'/'+string.join(contentVersionIdList,'/'); | |
system.debug('***downloadAllFileUrl:'+downloadAllFileUrl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment