DocuSign Inc.

01/19/2023 | News release | Distributed by Public on 01/19/2023 11:50

More than one way to bulk send envelopes with the Apex Toolkit

The Apex Toolkit lets you integrate DocuSign eSignature REST API functionality into Salesforce workflows and processes by exposing a full set of programmatic objects and methods that you can call from your Apex code. One of the most popular Apex Toolkit use cases is bulk sending, which lets you send an envelope to a list of recipients, each of whom will receive a copy to read or sign. If you've tried bulk sending with the Apex Toolkit, you may have seen our how-to guide on the subject. It demonstrates how to create and bulk send envelopes to the members of a Salesforce Chatter group. We often get questions about whether you can bulk send envelopes to recipients who are not all members of a Chatter group, and the answer is yes. In this blog post, I'll go over this and other options that you have for bulk sending with the Apex Toolkit.

As shown in the how-to, there are two main steps for bulk sending. The first is to build your list of recipients and the second is to bulk send the envelopes to the recipients in that list.

Build the recipient list

In the how-to, we build the contact list by looking at each member of a Chatter group in a loop and using their information to create a new recipient with the dfsle.Recipient.newBulkRecipient method. The code snippet below from the how-to demonstrates this.

In the snippet above, the loop includes an SOQL (Salesforce Object Query Language) query that returns objects. It then creates a object for each recipient returned from the SOQL query.

When you create a object, you can get the data to create that recipient from any source; it doesn't have to be related to a . For example, to include recipients in the bulk send who are not Chatter group members, you can modify the loop in the code above to instead choose objects from Salesforce. The code snippet below demonstrates how to build a bulk list using contacts that were created this month.

You can edit the SOQL query above with whatever conditions you need to build the list of Salesforce objects that you will use to create your bulk recipients.

Send the bulk envelopes

After you've built your list of bulk recipients, you need to send your bulk envelopes to those recipients. The code snippet below from the how-to guide demonstrates this.

Just as when building your list of bulk recipients, you have options when creating your bulk envelope. In the snippet above, the envelope is created using a document from a template. Templates are useful for bulk sending because they provide you with a flexible document that can be reused for many bulk envelopes. However, if you would prefer to create your document from a file stored in Salesforce, you can edit the code above and replace the method with the fromFile method.

Check out How to bulk send envelopes on the DocuSign Developer Center for more details on bulk sending with the Apex Toolkit, and check out the Apex Toolkit reference to learn more about the different ways that you can tailor our code examples to your specific use cases.

Additional resources