Skip to main content
Question

Pre Fill tab Values from Salesforce Apex Toolkit

  • 8 July 2024
  • 1 reply
  • 49 views

Hi!
 

I have a question regarding tabs. I have a document template where i have placed some text tabs and i want to reference those tabs inside apex so that i can pre fill a value in those tabs when the envelope is sent. So i do not want to create a text tab in apex and place it on the document but i want to pre fill a tab that already exists in the document template by somehow referencing it in my apex code.

Is that possible?

 

Thank you!

1 reply

Badge +1

@Gianluca Ferrante, to pre fill a tab that already exists in the document template you can send an envelope with merge fields using the Apex Toolkit as follows.

 

1. Create the envelope definition from a template

https://developers.docusign.com/docs/salesforce/how-to/send-envelope/

 

2.Define a merge field and text tab

 

//Define a merge field
//This field will be associated with the initiating source object represented by mySourceId
        dfsle.Tab.MergeField myMergeField = new dfsle.Tab.MergeField (
    'opportunity.name', //The data that this merge field will pull its value from
    null, //N/A
    null, //N/A
    true, //Allows writeback to the Salesforce object
    false //Whether or not the field is read only for the sender
);

        //Create a text tab that will be mapped to the merge field        
        dfsle.Tab myTextTab = new dfsle.TextTab()
           .withMergeField(myMergeField) //Associate this tab with the mergeField
            .withReadOnly(false) //true = read only or locked 
            .withDataLabel('Contact Name'); // The label of the tab. use this to reference existing tab

 

​​​​​​​3.Add the tab to the recipient

 

dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(

myContact.Name, // Signer name

myContact.Email, // Signer email

null, // Signer phone number

null, // Template role 

null) // No Salesforce association

.withTabs(new List<dfsle.Tab> { // Associate the tabs with this recipient

myTextTab

});

 

https://developers.docusign.com/docs/salesforce/how-to/send-envelope-with-merge-fields/

Reply