Salesforce Apex code to grab files and add to a template
Hello,
We have adobe sign templates set up. They work perfectly and are attached to the correct master object and record. Now, we would like to have the template populate with all files on that record that match a naming convention (ie. start with "APP-").
Adobe support gave me a base Apex code to start from, but I need help knowing what to change in order to have it add ALL files on that record that match the naming convention, and how to properly set it up in Salesforce.
Here's the code they provided:
public static Id AgrId;
AgrId = echosign_dev1.AgreementTemplateService.load('a2K5e000000bNXVEA2','a104X00000VBtWLQA1');
System.debug(AgrId);
ContentDocumentLink cDocLink = new ContentDocumentLink();
cDocLink.ContentDocumentId = '0694X00000MFKXlQAP';//Add ContentDocumentId
cDocLink.LinkedEntityId = AgrId;//Add attachment parentId
cDocLink.ShareType = 'V';//V – Viewer permission. C – Collaborator permission. I – Inferred permission.
cDocLink.Visibility = 'AllUsers';//AllUsers, InternalUsers, SharedUsers
Insert cDocLink;
