Matt LeDonne
Matt LeDonne

Reputation: 1

Show related records in Envelope with DocuSign Apex Toolkit

I am working to sent out documents within Salesforce on a daily basis when certain CPQ Quotes meet certain criteria. This would be a scheduled process and I created a DocuSign Envelope Template for the document that needs sent out. I am leveraging the Apex Toolkit since this is meant to be an automated process.

In the Document, I need to show the related child Quote Line records in a table as well. With the toolkit I can add in simple tabs using anchor text placed in the document. I attempted to configure the anchor text in the template builder UI within Salesforce but haven't had luck with that pulling in the data that I need.

Is the Toolkit capable of building a table for related records or is it leveraged more for very simple tabs to show data and not build something so dynamic?

Upvotes: 0

Views: 267

Answers (1)

Byungjae Chung
Byungjae Chung

Reputation: 36

You can take the records in Salesforce with the SOQL query and put that data into the tab. For example, in the case of setting the recipient, you can retrieve the Contact record in Salesforce with SOQL query and send the envelope by putting that data into the Recipient object.

//we will use a Salesforce contact record as a Recipient here
Contact myContact = [SELECT Id, Name, Email FROM Contact LIMIT 1];

//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
            myContact.Name, // Recipient name
            myContact.Email, // Recipient email
            null, //Optional phone number
            'Signer 1', //Role Name. Specify the exact role name from template
            new dfsle.Entity(myContact.Id)); //source object for the Recipient

//add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });

Upvotes: 0

Related Questions