Skip to navigation

BulkSendService

View as Markdown
global with sharing class BulkSendService
Description
Operations related to sending Docusign envelopes in bulk. Bulk send lists may be created, updated, and deleted. These may be reused with multiple draft envelopes. Only one SIGNER recipient per envelope copy is currently supported.

To use automatic anchor tags for the bulk envelope recipient, set the placeholder recipient role to dfsle.RecipientService.getDefaultRoles()[0], assuming it exists.

A typical flow is as follows:

 // Construct bulk list from a group
 dfsle.BulkList myList = new dfsle.BulkList(
  null, // Salesforce list ID. Assigned upon creation.
  null, // Docusign list ID. Assigned upon creation.
  new List<dfsle.Envelope> { ... }, // Envelope copies.
  new dfsle.Entity(mySalesforceGroupId));
 // Create the bulk send list.
 myList = dfsle.BulkSendService.createLists(new List<BulkList> { myBulkList })[0];
 // Create a draft envelope with at least one dummy recipient.
 dfsle.Envelope myEnvelope = dfsle.BulkSendService.getDraftEnvelope(
   new List<dfsle.Document> { ... }, // Documents
   new dfsle.Entity(mySalesforceSourceId)); // Salesforce source entity
 // Send the envelope to your bulk send list.
 dfsle.BulkList.Result myResult = dfsle.BulkSendService.sendEnvelope(myList.id, myEnvelope);
 // Check for and resolve any errors in the result.
 if (myResult.success) {
   // Get batch job status (will only call Docusign API at most once per minute)
   dfsle.BulkList.Status myStatus = dfsle.BulkSendService.getStatus(new Set<Id> { myResult.bulkStatusId });
 }
 

Methods

global static List<BulkList> createLists(final List<BulkList> bulkLists)
Description
Creates one or more bulk send lists in Salesforce and Docusign. The lists must have at least one member. Each list may be reused to send multiple envelopes. Currently bulk envelope copies are restricted to exactly one recipient each.

Callers must be assigned the DocuSign User permission set.

Returns
The newly-created bulk send lists.
Parameters
bulkLists
final List<BulkList> bulkLists
The bulk send lists to create.
global static Boolean deleteLists(final Set<Id> bulkListIds)
Description
Deletes one or more bulk send lists in Salesforce and Docusign.

Callers must be assigned the DocuSign User permission set.

Returns
The result of the delete operation: true if the lists were deleted, and false otherwise.
Parameters
bulkListIds
final Set<Id> bulkListIds
The IDs of the lists to delete.
global static Envelope getDraftEnvelope(final List<Document> documents, final Entity source)
Description
Gets a new bulk draft envelope instance with a single bulk recipient placeholder and default email and notification settings. This may be further customized via the dfsle.Envelope.withEmail or dfsle.Envelope.withNotifications methods.

Callers must be assigned the DocuSign User permission set.

Returns
A new bulk envelope instance.
Parameters
documents
final List<Document> documents
List of envelope documents. At least one document is required.
source
final Entity source
Optional Salesforce source object for the envelope.
global static List<BulkList.Status> getStatus(final Set<Id> bulkStatusIds)
Description
Retrieves status for one or more bulk send jobs.

Callers must be assigned the DocuSign User permission set.

Returns
A list of bulk send job statuses.
Parameters
bulkStatusIds
final Set<Id> bulkStatusIds
The list of status IDs.
global static List<BulkList> searchLists(final String name, final Integer maximumRecords)
Description
Searches for bulk send lists partially matching a name.

Callers must be assigned the DocuSign User permission set.

Returns
Bulk send lists matching the search criteria.
Parameters
name
final String name
The beginning part of the name to match.
maximumRecords
final Integer maximumRecords
The maximum number of records to retrieve.
global static BulkList.Result sendEnvelope(final Id bulkListId, final Envelope envelope)
Description
Sends an envelope to a bulk send list. The envelope will be created in Docusign and Salesforce.

If previously created, the caller must be the owner of the envelope. Otherwise the caller must be assigned the DocuSign User permission set.

Returns
The result of the bulk send operation.
Parameters
bulkListId
final Id bulkListId
The bulk send list Salesforce ID.
envelope
final Envelope envelope
The draft envelope.
global static List<BulkList> updateLists(final List<BulkList> bulkLists)
Description
Updates one or more bulk send lists in Salesforce and Docusign. Currently bulk envelope copies are restricted to exactly one recipient each.

This method should be called any time the source Salesforce group membership changes to ensure the lists are synchronized.

Callers must be assigned the DocuSign User permission set.

Returns
The updated bulk send lists.
Parameters
bulkLists
final List<BulkList> bulkLists
The bulk send lists to update.