• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Salesforce Apex code to grab files and add to a template

New Here ,
Sep 29, 2022 Sep 29, 2022

Copy link to clipboard

Copied

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;

TOPICS
Manage documents , Workflow designer

Views

324

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 29, 2022 Sep 29, 2022

Copy link to clipboard

Copied

LATEST

Also, I'm thinking this might help:  https://developer.salesforce.com/docs/atlas.en-us.238.0.object_reference.meta/object_reference/sforc......Maybe I need to replace the entire ContentDocumentLink section above with some kind of looping query?  And then build a flow?

Or maybe I should just be building a flow, period, to locate the files and then somehow shove them into my template files list?  

 

(sigh...I know just enough to be dangerous and not enough to make it work).  Help?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines