Signature

global static void execute(
  List<GenerateDocumentBatch.FlowInput> inputs
)
Parameters
ParameterDescription
inputs
List<GenerateDocumentBatch.FlowInput>
requiredOne entry per document group. Each FlowInput carries the documents to generate and the optional signing settings for that group. See the field breakdown below.

FlowInput

FlowInput
ParameterDescription
inputs
List<GenerateDocumentFlowInput>
requiredThe documents to generate in this group. Each entry describes one document.
signingSettings
GenerateDocumentSigningSettings
optionalCombined-envelope signing options for this group. Leave empty for the default behavior (one envelope per document).

GenerateDocumentFlowInput

GenerateDocumentFlowInput
ParameterDescription
templateId
String
requiredId of the CloudFiles template to render.
documentType
String
requiredOutput document type, for example 'docx' or 'pdf'.
recordId
String
optionalRecord Id the document is generated for.
cloudFilesVariables optionalMerge variables for the template, each a key and value.
destination optionalWhere the generated document is stored.
params optionalAdditional generation parameters such as PDF security and retention settings.

GenerateDocumentSigningSettings

GenerateDocumentSigningSettings
ParameterDescription
combineDocuments
Boolean
optionalWhen true, all documents in this group are sent for signature together as one DocuSign envelope. Signers receive a single email and the signed documents are delivered together.
emailSubject
String
optionalSubject of the DocuSign envelope email. Defaults to the first document's template signing settings.
emailMessage
String
optionalMessage body of the DocuSign envelope email. Defaults to the first document's template signing settings.

Return Type

void

Example

// Build one or more document inputs
cldfs.GenerateDocumentFlowInput docInput = new cldfs.GenerateDocumentFlowInput();
docInput.templateId = '681b4169c697ffdc2aab2731';
docInput.documentType = 'pdf';
docInput.recordId = '003dL00000YsapJQAR';
docInput.destination = new cldfs.Resource(
  '68887db5ef0b3ca7534dbbd5',
  'folder',
  null,
  'cloudfiles',
  'workspace'
);
docInput.params = new cldfs.DocGenParams();

// Optional: send the whole group as one DocuSign envelope
cldfs.GenerateDocumentSigningSettings signingSettings = new cldfs.GenerateDocumentSigningSettings();
signingSettings.combineDocuments = true;
signingSettings.emailSubject = 'Please sign your documents';

cldfs.GenerateDocumentBatch.FlowInput input = new cldfs.GenerateDocumentBatch.FlowInput();
input.inputs = new List<cldfs.GenerateDocumentFlowInput>{ docInput };
input.signingSettings = signingSettings;

cldfs.GenerateDocumentBatch.execute(
  new List<cldfs.GenerateDocumentBatch.FlowInput>{ input }
);
Combined-envelope signing & Batch Apex support

Each processed input publishes a Document Generated event; if generation or signing fails, an Error Event is published for that input.

Set combineDocuments = true on the signing settings to send every document in the group as a single DocuSign envelope, so signers get one email and sign everything in one session and the signed documents are delivered together. Leave the signing settings empty to keep the default behavior of one envelope per document.

The action runs asynchronously and can be invoked from Batch Apex or other asynchronous (future / queueable) contexts.